Showing posts with label rss feed. Show all posts
Showing posts with label rss feed. Show all posts

Monday, 24 October 2011

How to add custom content to RSS Feed posts in wordpress?


In the previous posts I shared how to add custom content to wordpress posts. Now I will share you how to add custom content to RSS feeds.
RSS (Rich Site Summary) is a format for delivering regularly changing web content. Now a day the sites using RSS feeds are increasing rapidly. Any end user may subscribe to the site RSS feeds .The users who subscribed will get all the latest updates, the user will directly go to the RSS feed our website and see the posts. Like this we may increase the number of users but the subscribed user even won’t come back to our website.

To make our subscribers to visit our home page frequently here is the solution. Add the site home link to all your RSS feeds. To achieve this add the following code to your theme functions.php file.

function addToRSS($content) { return $content.'Remember to stop by at Indian Recipes '; }
add_filter('the_excerpt_rss', 'addToRSS');
add_filter('the_content_rss', 'addToRSS');

Monday, 3 October 2011

How to add custom content to each post automatically?




Many bloggers will have a habit to write custom content after each post. Like “We welcome your suggestions on this blog “ Or something like ask readers to subscribe their RSS feed “If you like this post subscribe to our rss feed”.

We can hard code this content after the post content or we can add it every time when we write a new post. Adding this content every time, when we write a new article is not the right choice.

To automate this one add the following code to your theme functions.php i.e

function addFootNote($content) {
        if(is_feed() || is_single()) {
                $content.= "<div class='subscribes'>";
                $content.= "<h4>like this article?</h4>";
                $content.= "<p>Subscribe to our  <a href='http://feeds2.feedburner.com/wordpressnotes>RSS feed</a> </p>";
                $content.= "</div>";
        }

        return $content;
}

Tuesday, 27 September 2011

How to avoid the “XML Parsing Error: XML or text declaration not at start of entity” in wordpress feed?


Web feed or news feed is a format which is to represent the updated data for the users or subscribers. Wordpress has in built functionality for the generation of rss feeds for website.

Sometimes while accessing the rss feed it will throw a parsing error i.e

XML Parsing Error: XML or text declaration not at start of entity.


This error will cause if there is a blank space in the theme files or in the core files of wordpress.
To avoid this error remove the blank spaces before or after the <?php ?> tags  or add the following code.

We have different plug-ins to check the spaces in the files and to remove ,but the best solution is to add the following code. I resolved the problem is like this only. Adding a piece of code is better than using one more plugin for a website.Its better to use very less plug-ins for a website.

$out = ob_get_contents();  
$out = str_replace(array("\n", "\r", "\t", " "), "", $input);
ob_end_clean();

Add this code in the following files ,located root directory of your  wordpress site.

feed-atom.php
feed-atom-comments.php
feed-rdf.php
feed-rss.php
feed-rss2.php
feed-rss2-comments.php