How to create additional full text RSS feeds

At the risk of sounding completely ridiculous, I’m posting this question here as the nature of my query doesn’t seem to help me much from google.

My WordPress default RSS feeds makes use of post excerpt this feed is accessed via www.mydomain.com/feed

Read More

I have a requirement to make another RSS feed that is the full text. How can create an additional RSS feed (that is private/given to only trusted parties)? Preferably using a function but a plugin (as a last resort).

Related posts

Leave a Reply

2 comments

  1. Here is how to create a custom feed:

    first create a new file in your theme’s directory , name it your-custom-feed.php and put this code inside

    <?php
    
         /**
          * custom RSS feed.
          *
          * @package WordPress
          */
    
         header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
         $more = 1;
    
        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'); wp_title_rss(); ?></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>
                    <comments><?php comments_link_feed(); ?></comments>
                    <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>
                    <?php the_category_rss('rss2') ?>
    
                    <guid isPermaLink="false"><?php the_guid(); ?></guid>
                    <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
                <?php if ( strlen( $post->post_content ) > 0 ) : ?>
                    <content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
                <?php else : ?>
                    <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
                <?php endif; ?>
    
                    <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
                    <slash:comments><?php echo get_comments_number(); ?></slash:comments>
            <?php rss_enclosure(); ?>
                <?php do_action('rss2_item'); ?>
                </item>
                <?php endwhile; ?>
            </channel>
        </rss>
    

    then add a simple function to call that template file using do_feed_$hook

    //load feed template
    function create_my_customfeed() {
        load_template( TEMPLATEPATH . 'your-custom-feed.php'); 
    }
    add_action('do_feed_mycustomfeed', 'create_my_customfeed', 10, 1);
    

    Now when you access http://yoursite.com/?feed=mycustomfeed you will get a full text feed, no mater what you define inside WordPress admin.

    Bonus

    if you want to create a rewrite rule for your custom feed so your url could be:

    http://yoursite.com/mycustomfeed.xml
    as well as a
    http://yoursite.com/feed/mycustomfeed/

    add this code to your functions.php file:

    //create feed rewirte rule

    function custom_feed_rewrite($wp_rewrite) {
        $feed_rules = array('feed/(.+)' => 'index.php?feed=' . $wp_rewrite->preg_index(1),'(.+).xml' => 'index.php?feed='. $wp_rewrite->preg_index(1));
        $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
    }
    
  2. Try something like this (not tested, simplified from more complex code):

    add_feed('full', 'full_feed');
    
    function full_feed() {
    
        add_filter('pre_option_rss_use_excerpt', '__return_zero');
        load_template( ABSPATH . WPINC . '/feed-rss2.php' );
    }