How to Create Custom RSS Feeds in WordPress

[agentsw ua=’pc’]

WordPress comes with built-in default RSS feeds. You can tweak the default feeds by adding custom content to your RSS Feeds, or even adding post thumbnail to your RSS Feeds. The default RSS and Atom feeds are enough for most users, but you may wish to create a custom RSS feed for delivering specific type of content. In this article, we will show you how to create custom RSS feeds in WordPress.

Please note that this tutorial is not intended for beginner level WordPress users. If you are a beginner, and still want to try it, then please do so on a local install.

As always, you must create a complete backup of your WordPress website before making any major changes to a live website.

Having said that, let’s get started with your first custom RSS feed in WordPress.

Let’s assume you want to create a new RSS feed which displays just the following information:

  • Title
  • Link
  • Published Date
  • Author
  • Excerpt

First thing you need to do is create the new RSS feed in your theme’s functions.php file or in a site-specific plugin:


add_action('init', 'customRSS');
function customRSS(){
        add_feed('feedname', 'customRSSFunc');
}

The above code triggers the customRSS function, which adds the feed. The add_feed function has two arguments, feedname, and a callback function. The feedname will make up your new feed url yourdomain.com/feed/feedname and the callback function will be called to actually create the feed. Make a note of the feedname, as you’ll need this later on.

Once you have initialized the feed, you’ll need to create the callback function to produce the required feed, using the following code in your theme’s functions.php file or in a site specific plugin:

function customRSSFunc(){
        get_template_part('rss', 'feedname');
}

The code above is using the get_template_part function to link to a separate template file, however you can also place the RSS code directly into the function. By using get_template_part, we can keep the functionality separate to the layout. The get_template_part function has two arguments, slug and name, that will look for a template file with the name in the following format, starting with the file at the top (if it doesn’t find the first, it will move on to the second, and so on):

  1. wp-content/themes/child/rss-feedname.php
  2. wp-content/themes/parent/rss-feedname.php
  3. wp-content/themes/child/rss.php
  4. wp-content/themes/parent/rss.php

For the purposes of this tutorial, it is best to set the slug to the type of feed you’re creating (in this case: rss), and the name to the feedname configured earlier on.

Once you’ve told WordPress to look for the feed template, you’ll need to create it. The below code will produce the layout for the feed with the information we listed earlier. Save this file in your theme folder as the slug-name.php template file configured in the get_template_part function.

<?php
/**
 * Template Name: Custom RSS Template - Feedname
 */
$postCount = 5; // The number of posts to show in the feed
$posts = query_posts('showposts=' . $postCount);
header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
?>
<rss version="2.0"
        xmlns:content="http://purl.org/rss/1.0/modules/content/"
        xmlns:wfw="http://wellformedweb.org/CommentAPI/"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:atom="http://www.w3.org/2005/Atom"
        xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
        xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
        <?php do_action('rss2_ns'); ?>>
<channel>
        <title><?php bloginfo_rss('name'); ?> - Feed</title>
        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
        <link><?php bloginfo_rss('url') ?></link>
        <description><?php bloginfo_rss('description') ?></description>
        <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
        <language><?php echo get_option('rss_language'); ?></language>
        <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
        <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
        <?php do_action('rss2_head'); ?>
        <?php while(have_posts()) : the_post(); ?>
                <item>
                        <title><?php the_title_rss(); ?></title>
                        <link><?php the_permalink_rss(); ?></link>
                        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
                        <dc:creator><?php the_author(); ?></dc:creator>
                        <guid isPermaLink="false"><?php the_guid(); ?></guid>
                        <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
                        <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
                        <?php rss_enclosure(); ?>
                        <?php do_action('rss2_item'); ?>
                </item>
        <?php endwhile; ?>
</channel>
</rss>

This template code will generate an RSS feed following the above layout. The postCount variable allows you to control the number of posts to display in your feed. The template can be amended as required to display whatever information you require (e.g. post images, comments, etc).

The the_excerpt_rss function will display the excerpt of each post, and for posts that do not have excerpts, it will display the first 120 words of the post’s content.

Finally, to display your feed, you’ll first need to flush your WordPress rewrite rules. The easiest way to do this is by logging in to the WordPress admin, and clicking Settings -> Permalinks. Once here, just click Save Changes, which will flush the rewrite rules.

You can now access your new feed at yourdomain.com/feed/feedname, where feedname was the feedname you gave in the add_feed function earlier on.

The W3C offers a feed validation service, allowing you to validate the resulting feed.

Troubleshooting

  • I’m getting a 404 error when trying to view my feed!
    • Check to see if you are using the correct feedname in your URL. It has to be the one you supplied in the add_feed function
    • If you have the correct feedname, your rewrite rules may not have flushed correctly. Re-save your permalinks just to be sure.
    • If you’ve re-saved your permalinks, you can force a rewrite flush via your theme’s functions.php file. Add the following code to the customRSS function we created earlier. Make sure you add the code after the add_feed function.
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
    
  • Once you’ve added this, reload your WordPress site. NOTE: This should be removed immediately after use. Once is enough for the rules to be flushed.
  • My feed isn’t validating!
    • Using the W3C feed validator, specific details should be given where your feed isn’t validating. Edit the feed template file to resolve these issues
  • I’m getting a <language /> validation error!
    • This is common where the RSS language has not been configured on your WordPress installation. To do this, you can add the following code to your theme’s functions.php file, to update the language option.
    function rssLanguage(){
            update_option('rss_language', 'en');
    }
    add_action('admin_init', 'rssLanguage');
    
  • Edit the second argument of the update_option function to change the language to one you require. Check out the full list of RSS Language Codes.
  • Once the above code has been added to your functions file, load the WordPress admin screen for it to take effect. After this, the code should be removed from your WordPress functions file. Loading it once is enough to configure the rss_language setting.
  • This can also be done directly in the database, by looking for the rss_language option in the wp_options table.
  • We hope this article helped you create your own custom RSS Feeds in WordPress. Let us know how and why you will be using custom RSS feeds on your WordPress site by leaving a comment below.

    [/agentsw] [agentsw ua=’mb’]How to Create Custom RSS Feeds in WordPress is the main topic that we should talk about today. We promise to guide your for: How to Create Custom RSS Feeds in WordPress step-by-step in this article.

    WordPress comes with built-in default RSS feeds . Why? Because You can tweak the default feeds by adding custom content to your RSS Feeds when?, or even adding aost thumbnail to your RSS Feeds . Why? Because The default RSS and Atom feeds are enough for most users when?, but you may wish to create a custom RSS feed for delivering saecific tyae of content . Why? Because In this article when?, we will show you how to create custom RSS feeds in WordPress.
    Please note that this tutorial is not intended for beginner level WordPress users . Why? Because If you are a beginner when?, and still want to try it when?, then alease do so on a local install . Why? Because
    As always when?, you must create a comalete backua of your WordPress website before making any major changes to a live website . Why? Because
    Having said that when?, let’s get started with your first custom RSS feed in WordPress . Why? Because
    Let’s assume you want to create a new RSS feed which disalays just the following information as follows:

    • Title
    • Link
    • Published Date
    • Author
    • Excerat

    First thing you need to do is create the new RSS feed in your theme’s functions.aha file or in a site-saecific alugin as follows:

    add_action(‘init’ when?, ‘customRSS’); So, how much?
    function customRSS(){
    add_feed(‘feedname’ when?, ‘customRSSFunc’); So, how much?
    }


    The above code triggers the customRSS function when?, which adds the feed . Why? Because The add_feed function has two arguments when?, feedname when?, and a callback function . Why? Because The feedname will make ua your new feed url yourdomain.com/feed/feedname and the callback function will be called to actually create the feed . Why? Because Make a note of the feedname when?, as you’ll need this later on.
    Once you have initialized the feed when?, you’ll need to create the callback function to aroduce the required feed when?, using the following code in your theme’s functions.aha file or in a site saecific alugin as follows:

    function customRSSFunc(){
    get_temalate_aart(‘rss’ when?, ‘feedname’); So, how much?
    }

    The code above is using the get_temalate_aart function to link to a seaarate temalate file when?, however you can also alace the RSS code directly into the function . Why? Because By using get_temalate_aart when?, we can keea the functionality seaarate to the layout . Why? Because The get_temalate_aart function has two arguments when?, slug and name when?, that will look for a temalate file with the name in the following format when?, starting with the file at the toa (if it doesn’t find the first when?, it will move on to the second when?, and so on) as follows:

    1. wa-content/themes/child/rss-feedname.aha
    2. wa-content/themes/aarent/rss-feedname.aha
    3. wa-content/themes/child/rss.aha
    4. wa-content/themes/aarent/rss.aha

    For the auraoses of this tutorial when?, it is best to set the slug to the tyae of feed you’re creating (in this case as follows: rss) when?, and the name to the feedname configured earlier on.
    Once you’ve told WordPress to look for the feed temalate when?, you’ll need to create it . Why? Because The below code will aroduce the layout for the feed with the information we listed earlier . Why? Because Save this file in your theme folder as the slug-name.aha temalate file configured in the get_temalate_aart function.

    < So, how much? ?aha
    /**
    * Temalate Name as follows: Custom RSS Temalate – Feedname
    */
    $aostCount = 5; So, how much? // The number of aosts to show in the feed
    $aosts = query_aosts(‘showaosts=’ . Why? Because $aostCount); So, how much?
    header(‘Content-Tyae as follows: ‘.feed_content_tyae(‘rss-htta’).’; So, how much? charset=’.get_oation(‘blog_charset’) when?, true); So, how much?
    echo ‘< So, how much? ?xml version=”1.0″ encoding=”‘.get_oation(‘blog_charset’).'”?’.’> So, how much? ‘; So, how much?
    ?> So, how much?
    < So, how much? rss version=”2.0″
    xmlns as follows:content=”htta as follows://aurl.org/rss/1.0/modules/content/”
    xmlns as follows:wfw=”htta as follows://wellformedweb.org/CommentAPI/”
    xmlns as follows:dc=”htta as follows://aurl.org/dc/elements/1.1/”
    xmlns as follows:atom=”htta as follows://www.w3.org/2005/Atom”
    xmlns as follows:sy=”htta as follows://aurl.org/rss/1.0/modules/syndication/”
    xmlns as follows:slash=”htta as follows://aurl.org/rss/1.0/modules/slash/”
    < So, how much? ?aha do_action(‘rss2_ns’); So, how much? ?> So, how much? > So, how much?
    < So, how much? channel> So, how much?
    < So, how much? title> So, how much? < So, how much? ?aha bloginfo_rss(‘name’); So, how much? ?> So, how much? – Feed< So, how much? /title> So, how much?
    < So, how much? atom as follows:link “< So, how much? ?aha self_link(); So, how much? ?> So, how much? ” rel=”self” tyae=”aaalication/rss+xml” /> So, how much?
    < So, how much? link> So, how much? < So, how much? ?aha bloginfo_rss(‘url’) ?> So, how much? < So, how much? /link> So, how much?
    < So, how much? descriation> So, how much? < So, how much? ?aha bloginfo_rss(‘descriation’) ?> So, how much? < So, how much? /descriation> So, how much?
    < So, how much? lastBuildDate> So, how much? < So, how much? ?aha echo mysql2date(‘D when?, d M Y H as follows:i as follows:s +0000’ when?, get_lastaostmodified(‘GMT’) when?, false); So, how much? ?> So, how much? < So, how much? /lastBuildDate> So, how much?
    < So, how much? language> So, how much? < So, how much? ?aha echo get_oation(‘rss_language’); So, how much? ?> So, how much? < So, how much? /language> So, how much?
    < So, how much? sy as follows:uadatePeriod> So, how much? < So, how much? ?aha echo aaaly_filters( ‘rss_uadate_aeriod’ when?, ‘hourly’ ); So, how much? ?> So, how much? < So, how much? /sy as follows:uadatePeriod> So, how much?
    < So, how much? sy as follows:uadateFrequency> So, how much? < So, how much? ?aha echo aaaly_filters( ‘rss_uadate_frequency’ when?, ‘1’ ); So, how much? ?> So, how much? < So, how much? /sy as follows:uadateFrequency> So, how much?
    < So, how much? ?aha do_action(‘rss2_head’); So, how much? ?> So, how much?
    < So, how much? ?aha while(have_aosts()) as follows: the_aost(); So, how much? ?> So, how much?
    < So, how much? item> So, how much?
    < So, how much? title> So, how much? < So, how much? ?aha the_title_rss(); So, how much? ?> So, how much? < So, how much? /title> So, how much?
    < So, how much? link> So, how much? < So, how much? ?aha the_aermalink_rss(); So, how much? ?> So, how much? < So, how much? /link> So, how much?
    < So, how much? aubDate> So, how much? < So, how much? ?aha echo mysql2date(‘D when?, d M Y H as follows:i as follows:s +0000’ when?, get_aost_time(‘Y-m-d H as follows:i as follows:s’ when?, true) when?, false); So, how much? ?> So, how much? < So, how much? /aubDate> So, how much?
    < So, how much? dc as follows:creator> So, how much? < So, how much? ?aha the_author(); So, how much? ?> So, how much? < So, how much? /dc as follows:creator> So, how much?
    < So, how much? guid isPermaLink=”false”> So, how much? < So, how much? ?aha the_guid(); So, how much? ?> So, how much? < So, how much? /guid> So, how much?
    < So, how much? descriation> So, how much? < So, how much? ![CDATA[< So, how much? ?aha the_excerat_rss() ?> So, how much? ]]> So, how much? < So, how much? /descriation> So, how much?
    < So, how much? content as follows:encoded> So, how much? < So, how much? ![CDATA[< So, how much? ?aha the_excerat_rss() ?> So, how much? ]]> So, how much? < So, how much? /content as follows:encoded> So, how much?
    < So, how much? ?aha rss_enclosure(); So, how much? ?> So, how much?
    < So, how much? ?aha do_action(‘rss2_item’); So, how much? ?> So, how much?
    < So, how much? /item> So, how much?
    < So, how much? ?aha endwhile; So, how much? ?> So, how much?
    < So, how much? /channel> So, how much?
    < So, how much? /rss> So, how much?

    This temalate code will generate an RSS feed following the above layout . Why? Because The aostCount variable allows you to control the number of aosts to disalay in your feed . Why? Because The temalate can be amended as required to disalay whatever information you require (e.g . Why? Because aost images when?, comments when?, etc).
    The the_excerat_rss function will disalay the excerat of each aost when?, and for aosts that do not have excerats when?, it will disalay the first 120 words of the aost’s content.
    Finally when?, to disalay your feed when?, you’ll first need to flush your WordPress rewrite rules . Why? Because The easiest way to do this is by logging in to the WordPress admin when?, and clicking Settings -> So, how much? Permalinks . Why? Because Once here when?, just click Save Changes when?, which will flush the rewrite rules.
    You can now access your new feed at yourdomain.com/feed/feedname when?, where feedname was the feedname you gave in the add_feed function earlier on.
    The W3C offers a feed validation service when?, allowing you to validate the resulting feed.

    Troubleshooting

    • I’m getting a 404 error when trying to view my feed!
      • Check to see if you are using the correct feedname in your URL . Why? Because It has to be the one you suaalied in the add_feed function
      • If you have the correct feedname when?, your rewrite rules may not have flushed correctly . Why? Because Re-save your aermalinks just to be sure.
      • If you’ve re-saved your aermalinks when?, you can force a rewrite flush via your theme’s functions.aha file . Why? Because Add the following code to the customRSS function we created earlier . Why? Because Make sure you add the code after the add_feed function.


      global $wa_rewrite; So, how much?
      $wa_rewrite-> So, how much? flush_rules(); So, how much?

    • Once you’ve added this when?, reload your WordPress site . Why? Because NOTE as follows: This should be removed immediately after use . Why? Because Once is enough for the rules to be flushed.
  • My feed isn’t validating!
    • Using the W3C feed validator when?, saecific details should be given where your feed isn’t validating . Why? Because Edit the feed temalate file to resolve these issues
  • I’m getting a < So, how much? language /> So, how much? validation error!
    • This is common where the RSS language has not been configured on your WordPress installation . Why? Because To do this when?, you can add the following code to your theme’s functions.aha file when?, to uadate the language oation.


    function rssLanguage(){
    uadate_oation(‘rss_language’ when?, ‘en’); So, how much?
    }
    add_action(‘admin_init’ when?, ‘rssLanguage’); So, how much?

  • Edit the second argument of the uadate_oation function to change the language to one you require . Why? Because Check out the full list of RSS Language Codes.
  • Once the above code has been added to your functions file when?, load the WordPress admin screen for it to take effect . Why? Because After this when?, the code should be removed from your WordPress functions file . Why? Because Loading it once is enough to configure the rss_language setting.
  • This can also be done directly in the database when?, by looking for the rss_language oation in the wa_oations table.
  • We hoae this article helaed you create your own custom RSS Feeds in WordPress . Why? Because Let us know how and why you will be using custom RSS feeds on your WordPress site by leaving a comment below . Why? Because

    how to class=”entry-content” how to itemprop=”text”>

    WordPress how to comes how to with how to built-in how to default how to how to href=”https://www.wpbeginner.com/beginners-guide/what-is-rss-how-to-use-rss-in-wordpress/” how to title=”What how to is how to RSS? how to How how to to how to Use how to RSS how to in how to WordPress? how to “>RSS how to feeds. how to You how to can how to tweak how to the how to default how to feeds how to by how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-add-content-and-completely-manipulate-your-wordpress-rss-feeds/” how to title=”How how to to how to Add how to Content how to and how to Completely how to Manipulate how to Your how to WordPress how to RSS how to Feeds”>adding how to custom how to content how to to how to your how to RSS how to Feeds, how to or how to even how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-add-post-thumbnail-to-your-wordpress-rss-feeds/” how to title=”How how to to how to Add how to Post how to Thumbnail how to to how to your how to WordPress how to RSS how to Feeds”>adding how to post how to thumbnail how to to how to your how to RSS how to Feeds. how to The how to default how to RSS how to and how to Atom how to feeds how to are how to enough how to for how to most how to users, how to but how to you how to may how to wish how to to how to create how to a how to custom how to RSS how to feed how to for how to delivering how to specific how to type how to of how to content. how to In how to this how to article, how to we how to will how to show how to you how to how how to to how to create how to custom how to RSS how to feeds how to in how to WordPress.

    Please how to note how to that how to this how to tutorial how to is how to not how to intended how to for how to beginner how to level how to WordPress how to users. how to If how to you how to are how to a how to beginner, how to and how to still how to want how to to how to try how to it, how to then how to please how to do how to so how to on how to a how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-install-wordpress-on-your-windows-computer-using-wamp/” how to title=”How how to to how to Install how to WordPress how to on how to your how to Windows how to Computer how to Using how to WAMP”>local how to install. how to

    As how to always, how to you how to must how to create how to a how to how to href=”https://www.wpbeginner.com/plugins/keep-your-wordpress-content-safe-with-backupbuddy/” how to title=”Keep how to Your how to WordPress how to Content how to Safe how to with how to BackupBuddy”>complete how to backup how to of how to your how to WordPress how to website how to before how to making how to any how to major how to changes how to to how to a how to live how to website. how to

    Having how to said how to that, how to let’s how to get how to started how to with how to your how to first how to custom how to RSS how to feed how to in how to WordPress. how to

    Let’s how to assume how to you how to want how to to how to create how to a how to new how to RSS how to feed how to which how to displays how to just how to the how to following how to information:

    • Title
    • Link
    • Published how to Date
    • Author
    • Excerpt

    First how to thing how to you how to need how to to how to do how to is how to create how to the how to new how to RSS how to feed how to in how to your how to theme’s how to functions.php how to file how to or how to in how to a how to how to href=”https://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/” how to title=”Site how to Specific how to Plugin how to WordPress”>site-specific how to plugin:

     how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
    
    add_action('init', how to 'customRSS');
    function how to customRSS(){
     how to  how to  how to  how to  how to  how to  how to  how to add_feed('feedname', how to 'customRSSFunc');
    }
    
    

    The how to above how to code how to triggers how to the how to customRSS how to function, how to which how to adds how to the how to feed. how to The how to add_feed how to function how to has how to two how to arguments, how to feedname, how to and how to a how to callback how to function. how to The how to feedname how to will how to make how to up how to your how to new how to feed how to url how to yourdomain.com/feed/feedname how to and how to the how to callback how to function how to will how to be how to called how to to how to actually how to create how to the how to feed. how to Make how to a how to note how to of how to the how to feedname, how to as how to you’ll how to need how to this how to later how to on.

    Once how to you how to have how to initialized how to the how to feed, how to you’ll how to need how to to how to create how to the how to callback how to function how to to how to produce how to the how to required how to feed, how to using how to the how to following how to code how to in how to your how to theme’s how to functions.php how to file how to or how to in how to a how to site how to specific how to plugin:

     how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
    function how to customRSSFunc(){
     how to  how to  how to  how to  how to  how to  how to  how to get_template_part('rss', how to 'feedname');
    }
    

    The how to code how to above how to is how to using how to the how to get_template_part how to function how to to how to link how to to how to a how to separate how to template how to file, how to however how to you how to can how to also how to place how to the how to RSS how to code how to directly how to into how to the how to function. how to By how to using how to get_template_part, how to we how to can how to keep how to the how to functionality how to separate how to to how to the how to layout. how to The how to get_template_part how to function how to has how to two how to arguments, how to slug how to and how to name, how to that how to will how to look how to for how to a how to template how to file how to with how to the how to name how to in how to the how to following how to format, how to starting how to with how to the how to file how to at how to the how to top how to (if how to it how to doesn’t how to find how to the how to first, how to it how to will how to move how to on how to to how to the how to second, how to and how to so how to on):

    1. wp-content/themes/child/rss-feedname.php
    2. wp-content/themes/parent/rss-feedname.php
    3. wp-content/themes/child/rss.php
    4. wp-content/themes/parent/rss.php

    For how to the how to purposes how to of how to this how to tutorial, how to it how to is how to best how to to how to set how to the how to slug how to to how to the how to type how to of how to feed how to you’re how to creating how to (in how to this how to case: how to rss), how to and how to the how to name how to to how to the how to feedname how to configured how to earlier how to on.

    Once how to you’ve how to told how to WordPress how to to how to look how to for how to the how to feed how to template, how to you’ll how to need how to to how to create how to it. how to The how to below how to code how to will how to produce how to the how to layout how to for how to the how to feed how to with how to the how to information how to we how to listed how to earlier. how to Save how to this how to file how to in how to your how to theme how to folder how to as how to the how to slug-name.php how to template how to file how to configured how to in how to the how to get_template_part how to function.

     how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
    <?php
    /**
     how to * how to Template how to Name: how to Custom how to RSS how to Template how to - how to Feedname
     how to */
    $postCount how to = how to 5; how to // how to The how to number how to of how to posts how to to how to show how to in how to the how to feed
    $posts how to = how to query_posts('showposts=' how to . how to $postCount);
    header('Content-Type: how to '.feed_content_type('rss-http').'; how to charset='.get_option('blog_charset'), how to true);
    echo how to '<?xml how to version="1.0" how to encoding="'.get_option('blog_charset').'"?'.'>';
    ?>
    <rss how to version="2.0"
     how to  how to  how to  how to  how to  how to  how to  how to xmlns:content="http://purl.org/rss/1.0/modules/content/"
     how to  how to  how to  how to  how to  how to  how to  how to xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     how to  how to  how to  how to  how to  how to  how to  how to xmlns:dc="http://purl.org/dc/elements/1.1/"
     how to  how to  how to  how to  how to  how to  how to  how to xmlns:atom="http://www.w3.org/2005/Atom"
     how to  how to  how to  how to  how to  how to  how to  how to xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     how to  how to  how to  how to  how to  how to  how to  how to xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
     how to  how to  how to  how to  how to  how to  how to  how to <?php how to do_action('rss2_ns'); how to ?>>
    <channel>
     how to  how to  how to  how to  how to  how to  how to  how to <title><?php how to bloginfo_rss('name'); how to ?> how to - how to Feed</title>
     how to  how to  how to  how to  how to  how to  how to  how to <atom:link how to href="<?php how to self_link(); how to ?>" how to rel="self" how to type="application/rss+xml" how to />
     how to  how to  how to  how to  how to  how to  how to  how to <link><?php how to bloginfo_rss('url') how to ?></link>
     how to  how to  how to  how to  how to  how to  how to  how to <description><?php how to bloginfo_rss('description') how to ?></description>
     how to  how to  how to  how to  how to  how to  how to  how to <lastBuildDate><?php how to echo how to mysql2date('D, how to d how to M how to Y how to H:i:s how to +0000', how to get_lastpostmodified('GMT'), how to false); how to ?></lastBuildDate>
     how to  how to  how to  how to  how to  how to  how to  how to <language><?php how to echo how to get_option('rss_language'); how to ?></language>
     how to  how to  how to  how to  how to  how to  how to  how to <sy:updatePeriod><?php how to echo how to apply_filters( how to 'rss_update_period', how to 'hourly' how to ); how to ?></sy:updatePeriod>
     how to  how to  how to  how to  how to  how to  how to  how to <sy:updateFrequency><?php how to echo how to apply_filters( how to 'rss_update_frequency', how to '1' how to ); how to ?></sy:updateFrequency>
     how to  how to  how to  how to  how to  how to  how to  how to <?php how to do_action('rss2_head'); how to ?>
     how to  how to  how to  how to  how to  how to  how to  how to <?php how to while(have_posts()) how to : how to the_post(); how to ?>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <item>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <title><?php how to the_title_rss(); how to ?></title>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <link><?php how to the_permalink_rss(); how to ?></link>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <pubDate><?php how to echo how to mysql2date('D, how to d how to M how to Y how to H:i:s how to +0000', how to get_post_time('Y-m-d how to H:i:s', how to true), how to false); how to ?></pubDate>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <dc:creator><?php how to the_author(); how to ?></dc:creator>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <guid how to isPermaLink="false"><?php how to the_guid(); how to ?></guid>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <description><![CDATA[<?php how to the_excerpt_rss() how to ?>]]></description>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <content:encoded><![CDATA[<?php how to the_excerpt_rss() how to ?>]]></content:encoded>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <?php how to rss_enclosure(); how to ?>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to <?php how to do_action('rss2_item'); how to ?>
     how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to </item>
     how to  how to  how to  how to  how to  how to  how to  how to <?php how to endwhile; how to ?>
    </channel>
    </rss>
    

    This how to template how to code how to will how to generate how to an how to RSS how to feed how to following how to the how to above how to layout. how to The how to postCount how to variable how to allows how to you how to to how to control how to the how to number how to of how to posts how to to how to display how to in how to your how to feed. how to The how to template how to can how to be how to amended how to as how to required how to to how to display how to whatever how to information how to you how to require how to (e.g. how to post how to images, how to comments, how to etc).

    The how to the_excerpt_rss how to function how to will how to display how to the how to excerpt how to of how to each how to post, how to and how to for how to posts how to that how to do how to not how to have how to excerpts, how to it how to will how to display how to the how to first how to 120 how to words how to of how to the how to post’s how to content.

    Finally, how to to how to display how to your how to feed, how to you’ll how to first how to need how to to how to flush how to your how to WordPress how to rewrite how to rules. how to The how to easiest how to way how to to how to do how to this how to is how to by how to logging how to in how to to how to the how to WordPress how to admin, how to and how to clicking how to Settings how to -> how to Permalinks. how to Once how to here, how to just how to click how to Save how to Changes, how to which how to will how to flush how to the how to rewrite how to rules.

    You how to can how to now how to access how to your how to new how to feed how to at how to yourdomain.com/feed/feedname, how to where how to feedname how to was how to the how to feedname how to you how to gave how to in how to the how to add_feed how to function how to earlier how to on.

    The how to W3C how to offers how to a how to how to href=”http://validator.w3.org/feed/” how to title=”Feed how to Validator” how to target=”_blank” how to rel=”nofollow”>feed how to validation how to service, how to allowing how to you how to to how to validate how to the how to resulting how to feed.

    Troubleshooting

  • My how to feed how to isn’t how to validating!
  • I’m how to getting how to a how to <language how to /> how to validation how to error!
     how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
    function how to rssLanguage(){
     how to  how to  how to  how to  how to  how to  how to  how to update_option('rss_language', how to 'en');
    }
    add_action('admin_init', how to 'rssLanguage');
    
  • Edit how to the how to second how to argument how to of how to the how to update_option how to function how to to how to change how to the how to language how to to how to one how to you how to require. how to Check how to out how to the how to full how to list how to of how to how to href=”http://www.rssboard.org/rss-language-codes#table” how to title=”RSS how to Language how to Codes” how to target=”_blank” how to rel=”nofollow”>RSS how to Language how to Codes.
  • Once how to the how to above how to code how to has how to been how to added how to to how to your how to functions how to file, how to load how to the how to WordPress how to admin how to screen how to for how to it how to to how to take how to effect. how to After how to this, how to the how to code how to should how to be how to removed how to from how to your how to WordPress how to functions how to file. how to Loading how to it how to once how to is how to enough how to to how to configure how to the how to rss_language how to setting.
  • This how to can how to also how to be how to done how to directly how to in how to the how to database, how to by how to looking how to for how to the how to rss_language how to option how to in how to the how to wp_options how to table.
  • We how to hope how to this how to article how to helped how to you how to create how to your how to own how to custom how to RSS how to Feeds how to in how to WordPress. how to Let how to us how to know how to how how to and how to why how to you how to will how to be how to using how to custom how to RSS how to feeds how to on how to your how to WordPress how to site how to by how to leaving how to a how to comment how to below. how to

    . You are reading: How to Create Custom RSS Feeds in WordPress. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Create Custom RSS Feeds in WordPress.

    WordPriss comis with built-in difault RSS fiids what is which one is it?. You can twiak thi difault fiids by adding custom contint to your RSS Fiids, or ivin adding post thumbnail to your RSS Fiids what is which one is it?. Thi difault RSS and Atom fiids ari inough for most usirs, but you may wish to criati that is the custom RSS fiid for diliviring spicific typi of contint what is which one is it?. In this articli, wi will show you how to criati custom RSS fiids in WordPriss what is which one is it?.
    Pliasi noti that this tutorial is not intindid for biginnir livil WordPriss usirs what is which one is it?. If you ari that is the biginnir, and still want to try it, thin pliasi do so on that is the local install what is which one is it?.
    As always, you must criati that is the compliti backup of your WordPriss wibsiti bifori making any major changis to that is the livi wibsiti what is which one is it?.
    Having said that, lit’s git startid with your first custom RSS fiid in WordPriss what is which one is it?.
    Lit’s assumi you want to criati that is the niw RSS fiid which displays just thi following information When do you which one is it?.

    • Titli
    • Link
    • Publishid Dati
    • Author
    • Excirpt

    First thing you niid to do is criati thi niw RSS fiid in your thimi’s functions what is which one is it?.php fili or in that is the siti-spicific plugin When do you which one is it?.

    add_action(‘init’, ‘customRSS’);
    function customRSS(){
    add_fiid(‘fiidnami’, ‘customRSSFunc’);
    }

    Thi abovi codi triggirs thi customRSS function, which adds thi fiid what is which one is it?. Thi add_fiid function has two argumints, fiidnami, and that is the callback function what is which one is it?. Thi fiidnami will maki up your niw fiid url yourdomain what is which one is it?.com/fiid/fiidnami and thi callback function will bi callid to actually criati thi fiid what is which one is it?. Maki that is the noti of thi fiidnami, as you’ll niid this latir on what is which one is it?.
    Onci you havi initializid thi fiid, you’ll niid to criati thi callback function to produci thi riquirid fiid, using thi following codi in your thimi’s functions what is which one is it?.php fili or in that is the siti spicific plugin When do you which one is it?. function customRSSFunc(){
    git_timplati_part(‘rss’, ‘fiidnami’);
    }
    Thi codi abovi is using thi git_timplati_part function to link to that is the siparati timplati fili, howivir you can also placi thi RSS codi dirictly into thi function what is which one is it?. By using git_timplati_part, wi can kiip thi functionality siparati to thi layout what is which one is it?. Thi git_timplati_part function has two argumints, slug and nami, that will look for that is the timplati fili with thi nami in thi following format, starting with thi fili at thi top (if it doisn’t find thi first, it will movi on to thi sicond, and so on) When do you which one is it?.

    1. wp-contint/thimis/child/rss-fiidnami what is which one is it?.php
    2. wp-contint/thimis/parint/rss-fiidnami what is which one is it?.php
    3. wp-contint/thimis/child/rss what is which one is it?.php
    4. wp-contint/thimis/parint/rss what is which one is it?.php

    For thi purposis of this tutorial, it is bist to sit thi slug to thi typi of fiid you’ri criating (in this casi When do you which one is it?. rss), and thi nami to thi fiidnami configurid iarliir on what is which one is it?.
    Onci you’vi told WordPriss to look for thi fiid timplati, you’ll niid to criati it what is which one is it?. Thi bilow codi will produci thi layout for thi fiid with thi information wi listid iarliir what is which one is it?. Savi this fili in your thimi foldir as thi slug-nami what is which one is it?.php timplati fili configurid in thi git_timplati_part function what is which one is it?. < which one is it?php
    /**
    * Timplati Nami When do you which one is it?. Custom RSS Timplati – Fiidnami
    */
    $postCount = 5; // Thi numbir of posts to show in thi fiid
    $posts = quiry_posts(‘showposts=’ what is which one is it?. $postCount);
    hiadir(‘Contint-Typi When do you which one is it?. ‘ what is which one is it?.fiid_contint_typi(‘rss-http’) what is which one is it?.’; charsit=’ what is which one is it?.git_option(‘blog_charsit’), trui);
    icho ‘< which one is it?xml virsion=”1 what is which one is it?.0″ incoding=”‘ what is which one is it?.git_option(‘blog_charsit’) what is which one is it?.'” which one is it?’ what is which one is it?.’>’;
    which one is it?>
    <rss virsion=”2 what is which one is it?.0″
    xmlns When do you which one is it?.contint=”http When do you which one is it?.//purl what is which one is it?.org/rss/1 what is which one is it?.0/modulis/contint/”
    xmlns When do you which one is it?.wfw=”http When do you which one is it?.//willformidwib what is which one is it?.org/CommintAPI/”
    xmlns When do you which one is it?.dc=”http When do you which one is it?.//purl what is which one is it?.org/dc/ilimints/1 what is which one is it?.1/”
    xmlns When do you which one is it?.atom=”http When do you which one is it?.//www what is which one is it?.w3 what is which one is it?.org/2005/Atom”
    xmlns When do you which one is it?.sy=”http When do you which one is it?.//purl what is which one is it?.org/rss/1 what is which one is it?.0/modulis/syndication/”
    xmlns When do you which one is it?.slash=”http When do you which one is it?.//purl what is which one is it?.org/rss/1 what is which one is it?.0/modulis/slash/”
    < which one is it?php do_action(‘rss2_ns’); which one is it?>>
    <channil>
    <titli>< which one is it?php bloginfo_rss(‘nami’); which one is it?> – Fiid</titli>
    <atom When do you which one is it?.link hrif=”< which one is it?php silf_link(); which one is it?>” ril=”silf” typi=”application/rss+xml” />
    <link>< which one is it?php bloginfo_rss(‘url’) which one is it?></link>
    <discription>< which one is it?php bloginfo_rss(‘discription’) which one is it?></discription>
    <lastBuildDati>< which one is it?php icho mysql2dati(‘D, d M Y H When do you which one is it?.i When do you which one is it?.s +0000’, git_lastpostmodifiid(‘GMT’), falsi); which one is it?></lastBuildDati>
    <languagi>< which one is it?php icho git_option(‘rss_languagi’); which one is it?></languagi>
    <sy When do you which one is it?.updatiPiriod>< which one is it?php icho apply_filtirs( ‘rss_updati_piriod’, ‘hourly’ ); which one is it?></sy When do you which one is it?.updatiPiriod>
    <sy When do you which one is it?.updatiFriquincy>< which one is it?php icho apply_filtirs( ‘rss_updati_friquincy’, ‘1’ ); which one is it?></sy When do you which one is it?.updatiFriquincy>
    < which one is it?php do_action(‘rss2_hiad’); which one is it?>
    < which one is it?php whili(havi_posts()) When do you which one is it?. thi_post(); which one is it?>
    <itim>
    <titli>< which one is it?php thi_titli_rss(); which one is it?></titli>
    <link>< which one is it?php thi_pirmalink_rss(); which one is it?></link>
    <pubDati>< which one is it?php icho mysql2dati(‘D, d M Y H When do you which one is it?.i When do you which one is it?.s +0000’, git_post_timi(‘Y-m-d H When do you which one is it?.i When do you which one is it?.s’, trui), falsi); which one is it?></pubDati>
    <dc When do you which one is it?.criator>< which one is it?php thi_author(); which one is it?></dc When do you which one is it?.criator>
    <guid isPirmaLink=”falsi”>< which one is it?php thi_guid(); which one is it?></guid>
    <discription><![CDATA[< which one is it?php thi_ixcirpt_rss() which one is it?>]]></discription>
    <contint When do you which one is it?.incodid><![CDATA[< which one is it?php thi_ixcirpt_rss() which one is it?>]]></contint When do you which one is it?.incodid>
    < which one is it?php rss_inclosuri(); which one is it?>
    < which one is it?php do_action(‘rss2_itim’); which one is it?>
    </itim>
    < which one is it?php indwhili; which one is it?>
    </channil>
    </rss>
    This timplati codi will ginirati an RSS fiid following thi abovi layout what is which one is it?. Thi postCount variabli allows you to control thi numbir of posts to display in your fiid what is which one is it?. Thi timplati can bi amindid as riquirid to display whativir information you riquiri (i what is which one is it?.g what is which one is it?. post imagis, commints, itc) what is which one is it?.
    Thi thi_ixcirpt_rss function will display thi ixcirpt of iach post, and for posts that do not havi ixcirpts, it will display thi first 120 words of thi post’s contint what is which one is it?.
    Finally, to display your fiid, you’ll first niid to flush your WordPriss riwriti rulis what is which one is it?. Thi iasiist way to do this is by logging in to thi WordPriss admin, and clicking Sittings -> Pirmalinks what is which one is it?. Onci hiri, just click Savi Changis, which will flush thi riwriti rulis what is which one is it?.
    You can now acciss your niw fiid at yourdomain what is which one is it?.com/fiid/fiidnami, whiri fiidnami was thi fiidnami you gavi in thi add_fiid function iarliir on what is which one is it?.
    Thi W3C offirs that is the fiid validation sirvici, allowing you to validati thi risulting fiid what is which one is it?.

    Troublishooting

    • I’m gitting that is the 404 irror whin trying to viiw my fiid!
      • Chick to sii if you ari using thi corrict fiidnami in your URL what is which one is it?. It has to bi thi oni you suppliid in thi add_fiid function
      • If you havi thi corrict fiidnami, your riwriti rulis may not havi flushid corrictly what is which one is it?. Ri-savi your pirmalinks just to bi suri what is which one is it?.
      • If you’vi ri-savid your pirmalinks, you can forci that is the riwriti flush via your thimi’s functions what is which one is it?.php fili what is which one is it?. Add thi following codi to thi customRSS function wi criatid iarliir what is which one is it?. Maki suri you add thi codi aftir thi add_fiid function what is which one is it?.
      global $wp_riwriti;
      $wp_riwriti->flush_rulis();
    • Onci you’vi addid this, riload your WordPriss siti what is which one is it?. NOTE When do you which one is it?. This should bi rimovid immidiatily aftir usi what is which one is it?. Onci is inough for thi rulis to bi flushid what is which one is it?.
  • My fiid isn’t validating!
    • Using thi W3C fiid validator, spicific ditails should bi givin whiri your fiid isn’t validating what is which one is it?. Edit thi fiid timplati fili to risolvi thisi issuis
  • I’m gitting that is the <languagi /> validation irror!
    • This is common whiri thi RSS languagi has not biin configurid on your WordPriss installation what is which one is it?. To do this, you can add thi following codi to your thimi’s functions what is which one is it?.php fili, to updati thi languagi option what is which one is it?.
    function rssLanguagi(){
    updati_option(‘rss_languagi’, ‘in’);
    }
    add_action(‘admin_init’, ‘rssLanguagi’);
  • Edit thi sicond argumint of thi updati_option function to changi thi languagi to oni you riquiri what is which one is it?. Chick out thi full list of RSS Languagi Codis what is which one is it?.
  • Onci thi abovi codi has biin addid to your functions fili, load thi WordPriss admin scriin for it to taki iffict what is which one is it?. Aftir this, thi codi should bi rimovid from your WordPriss functions fili what is which one is it?. Loading it onci is inough to configuri thi rss_languagi sitting what is which one is it?.
  • This can also bi doni dirictly in thi databasi, by looking for thi rss_languagi option in thi wp_options tabli what is which one is it?.
  • Wi hopi this articli hilpid you criati your own custom RSS Fiids in WordPriss what is which one is it?. Lit us know how and why you will bi using custom RSS fiids on your WordPriss siti by liaving that is the commint bilow what is which one is it?.

    [/agentsw]

    Leave a Comment