WordPress.org

Forums

How do I add code to a post easily? (4 posts)

  1. a_johnson
    Member
    Posted 5 years ago #

    For WP 2.9, I can't seem to figure out how to add this to a post. I am looking for a magic button I suppose, I know I can do it in HTML but want to do it after certain h2 tags and img tags to correct formatting problems in visual mode.

    I want to add:

    <div class="clear"> &nbsp; </div> to fix word wrap around other elements and:

    <p class="space"> &nbsp; </p> to add space between some elements like the text of a post and footnotes.

    CSS is:

    .clear { clear: both; }
    .space {line-height:1em; font-size: 1em; }

    Note that they work great, I just want a simple way to do it.

  2. a_johnson
    Member
    Posted 5 years ago #

    I guess no one knows.

  3. alchymyth
    Forum Moderator
    Posted 5 years ago #

  4. a_johnson
    Member
    Posted 5 years ago #

    Thank you for the reply. Using this example then, I should be able to do it.

    Example:

    function twitt() {
      return '<div id="twitit"><a href="http://twitter.com/home?status=Currently reading '.get_permalink($post->ID).'" title="Click to send this page to Twitter!" target="_blank">Share on Twitter</a></div>';
    }
    
    add_shortcode('twitter', 'twitt');

    New short code:

    function clear() {
      return '<div class="clear"> &nbsp; </div>';
    }
    
    add_shortcode('c', 'clear');

    So if I put [c] in the post, it should do what I want.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.