0

I'm sure this is a dup, but I honestly can't find an answer.

I'd like to add a message to the start and end of my posts:

"Check out my new startup: Facebook For Dogs!"

Is there a simple way to do this, hopefully using a plugin?

1
  • If the answer below solves you problem please click on the tick mark.
    – user983248
    May 7, 2012 at 12:38

1 Answer 1

5

You'll want to hook into the_content to add a message.

Something like this:

<?php
add_filter('the_content', 'wpse51338_filter_content');
/*
 * Filter the content to add a message before and after it.
 */
function wpse51338_filter_content($content)
{
    // not a singular post?  just return the content
    if(!is_singular())
        return $content;

    $msg = sprintf(
        '<p class="special-message">%s</p>',
        __('Here is an awesome message!', 'your_textdomain_string') // this is your message
    );
    return $msg . $content . $msg;
}

As a plugin.

2
  • Awesome, thanks. I should have mentioned I'm a complete newbie. How do I install this plugin? May 7, 2012 at 5:38
  • you can paste this code in your functions.php file ;) May 7, 2012 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.