• Resolved garbonzo

    (@garbonzo)


    I want to add a little bit of text automatically with each and every post, so I figure the best way is to hack the template a little.

    But which one?

    Or is there a better way?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • index.php.

    just put the text you want to appear in every post within the loop there. Be sure to put it where you want it to appear. if you want the text to show up before the post (but after the title), then put it there in the template. If you want it at the bototm of the post, put the text there after the comments/author section.

    That’s pretty much all there is to it 🙂

    Thread Starter garbonzo

    (@garbonzo)

    I meant into the post itself – if I add the text into index.php, it’ll get displayed along with the post, but wordpress won’t consider the added text to be part of the post.

    I need this special text to show up in each post in the rss feed, that’s why.

    Do you know which internal file I should hack?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You need to create a filter. A filter is a function which receives some text, does stuff to it, then returns the changed text. Filters can be added, removed, chained, etc, and they act on the text before the stuff makes it anywhere.

    The filter you want to add to is called “the_content”.

    So do something like this in your theme’s functions.php file:

    function add_my_stuff($content)
    {
    $content = "My added text ".$content;
    return $content;
    }
    add_filter('the_content','add_my_stuff');

    This will have the effect of changing the content of all posts in the same way, throughout the entire system. Webpages, RSS feeds, the works.

    Thread Starter garbonzo

    (@garbonzo)

    Yes! Thanks Otto.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do I force a piece of text into every single post?’ is closed to new replies.