Spacey Shortcode

January 15, 2016

Situation

Where a paragraph tag < p > or a break tag < br > just provide the spacing you need between on page elements.

Solution

  1. Add this code to your child theme functions.php file (you ARE using a child theme, aren’t you?!)
  2. Use shortcode [ spaceme height=”16″]
// Spacer Shortcode - User Adjustable.
// Usage: Use shortcode [ spaceme height="xx" ] where xx is a number denoting the height one wants in pixels. Default is 5px.
function spacey($atts) {
    extract(shortcode_atts(array(
      "height" =&gt; '5',
    ), $atts));

   return '&lt;div style="height: '. $height.'px; width: 100%; display: block;"&gt;&lt;/div&gt;';
}
add_shortcode('spaceme', 'spacey');

Demo

Thirty Five Pixel Space follows this paragraph. Fusce ac felis sit amet ligula pharetra condimentum. In hac habitasse platea dictumst. Praesent congue erat at massa. Morbi mollis tellus ac sapien. Vestibulum suscipit nulla quis orci.

Fifteen Pixel Space follows this paragraph. Vestibulum volutpat pretium libero. Fusce ac felis sit amet ligula pharetra condimentum. Maecenas ullamcorper, dui et placerat feugiat, eros pede varius nisi, condimentum viverra felis nunc et lorem. Cras risus ipsum, faucibus ut, ullamcorper id, varius ac, leo. Proin magna.

Five Pixel Space follows this paragraph. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. Sed aliquam ultrices mauris. Duis leo. Nunc nec neque. Proin magna.

Proin faucibus arcu quis ante. Nullam vel sem. Sed in libero ut nibh placerat accumsan. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. Fusce ac felis sit amet ligula pharetra condimentum.

mailbox email subscribe

Subscribe for Divi Freebies

Plugin update notifications :: stay abreast of new and or updated items by opting in to my very occasional email newsletter. I swear by all that is right and holy your email address will never be shared, sold, traded or otherwise abused and I seriously doubt you'll see anything more than plugin/code update notifications when they are of the utmost importance.

 

 

 

[give_form id="114248"]

Give a Shout Out

3 + 4 =

Pin It on Pinterest

Signup For Access To Free WordPress Tips & Resources

Signup For Access To Free WordPress Tips & Resources

Signup for our very occasional newsletter and get access to free downloads, as well as WordPress tips, tricks and resources.

You have Successfully Subscribed!