One kind of funny thing with WordPress is that entering HTML in the post window can sometimes lead to unexpected results. Sometimes WordPress (or probably more specifically the WYSIWYG visual editor) will eat some or all of the HTML. A friend of mine (Hi Chris!) was asking me how to add line breaks to her post. Adding the actual HTML for a line break didn't work because WordPress ate it. The simplest solution for this is to use shortcodes to get the HTML into the post without WordPress munching it.
To add the shortcode – go to your themes functions.php file (if you don't have this file in your theme, simply create a file called "functions.php" and throw it in your theme folder.) Then add the following code to this file (make sure the function name doesn't class with something else already in there just in case!)
function breakall() {
return '<br clear="all" />';
}
add_shortcode('br', 'breakall');
Now, when writing your posts, if you need to add a line break or two just add the following where you want the linebreak:
[br]
That will be converted to <br clear="all" /> when the page is displayed.
Shortcodes are an amazingly powerful little feature. Read more about shortcodes here:
Shortcode API
Mastering WordPress Shortcodes
10 Incredibly Cool WordPress Shortcodes
Related posts:
- Adding a block of HTML to a WordPress post One problem with the WYSIWYG editor in WordPress is that...
- Anchor Links in WordPress Posts – another shortcode solution I was recently asked by a client how they could...
- Conditionally change path to HTTPS One of my clients had set it up so that...
- Striping IMG tags from the_content in WordPress (and how to fudge page excerpts) Background: For a site I was working on, I was...
- Multiple Featured Content Galleries On a site I was working on recently, the client...
Related posts brought to you by Yet Another Related Posts Plugin.
scriptygoddess
