• I’ve found a bunch of plugins that allow me to insert content everywhere in a post: before, after, in the middle of, underneath, on top of, inside of…anyway, a bit of overkill. Is there a simple code I can throw in functions.php that allows me to put a simple line of HTML before the title of each post?

    I tried using this CSS to achieve this,

    #post-title:before {content: "<p class=pretitle>Today's episode</p>";}

    but CSS places it inline and I need it on the previous line.

    Oh, I also found PHP code telling me how to insert things in footnotes and at the end of each post, but I need this at the beginning.

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter goldenatlas

    (@goldenatlas)

    OK, here’s how I found to get text inserted at the bottom of a post, but I don’t understand how this function figures out WHERE to put the content…how do I tell it to place it at the top?

    <?php
    // add custom post content
    add_filter('the_content', 'add_post_content');
    function add_post_content($content) {
    $content .= '<p class=pre-title>Today’s Episode</p>';
    return $content;
    }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Adding content before a post’ is closed to new replies.