WordPress tutorials: Custom post content

Wpsnipp – For some reason, you may want to be able to automatically display a custom text below each of your posts. You can hard-code it, but it will be way better to do so using a WordPress hook. Here’s how to do.Adding this to your functions.php file in your wordpress theme will add content after each post. This can be something like a copyright or ad etc.

 

 

function add_post_content($content) {
if(!is_feed() && !is_home()) {
$content .= '<p>This article is copyright © '.date('Y').' '.bloginfo('name').'</p>';
}
return $content;
}
add_filter('the_content', 'add_post_content');

Leave a comment