Another WordPress Development Blog

Add custom content after(or before) each post


If you want to add custom content after each post you have 2 options: You edit the template or you use the wordpress filter function. The second method has the advantage of not editing the template files. You just need to copy paste the code below.


function custom_content($content) {
if(is_single()) {
$content .= 'add here the custom content';
}
return $content;
}
add_filter('the_content', 'custom_content');

Just edit the function above to add your information.

You can use the same function if you want to display the content before the post. Just replace the line
$content .= ‘add here the custom content’; with $content =’add here the custom content’.$content ;

Random Posts

Leave a Reply