metinsaylan // rogue developer

How to add text to every post in your feed

You can see some blog sites include related links, advertisements, and post relevant tags in their feed. This is very useful for your site’s popularity and increasing page hits. You can also add copyrights to your blogfeed to prevent RSS theft. Here I will explain you how to add any text in your wordpress feed.


You can easily do that using wordpress filters. Start with a new php file that you can use as a plugin file or theme functions file. Add the following line:

<?php add_filter('the_content', 'your_function_to_add_text',99); ?>

this code makes sure everytime content is needed your function will filter it. so we need to code our filter now:

function your_function_to_add_text($content) {
// if we are not in feed then
// skip and return content as it is.
	if ( ! is_feed() ) return $content;
// tip: you can use funtions to generate text
	$pcat = "<p> Categories: ".the_category(' ')." </p>";
	$content .= $pcat; // adding text to content
	$content .= "<br>";
   return ($content);
}

It’s all done! This tiny function adds post categories to the end of content when reached using a feed reader. You can add copyright, related post titles, ads and footers to every wordpress post in your feed using this simple filter.

Happy blogging!

Search How to add text to every post in your feed on Google