Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

prof611 on "Always show the full content feed, even in Firefox"

$
0
0

For several years now, I have been using my own hacked version of feed-rss2.php, so that the full content feed would always be shown, even in the Firefox browser. I know that the original version of the feed shows the full content in a REAL feed reader ( see http://wordpress.org/support/topic/rss-feed-wont-show-full-text-1 ), but since many of my viewers ( including me ) use Firefox to view their feeds, I wanted the feed to show the full content, even in this browser.

The problem with hacking the feed file directly is that every time I update WordPress, I must re-copy the hacked file - since it's in wp-admin, and this is updated every time WordPress puts out a new version. Since I have many blogs, this task was becoming odious.

So I decided to put my hacked version of rss2 into my child theme. After a lot of research ( I am a tyro at PHP coding ), I finally succeeded in doing this. Here is the contents of the functions.php file I added to my child theme:

<?php
// Include This Feed Function
// basic outline from http://codex.wordpress.org/Customizing_Feeds
// specific function code from http://themeshaper.com/2009/05/25/action-hooks-wordpress-child-themes/
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'full_content_feed_rss2' );

function full_content_feed_rss2() {
/* RSS2 Feed Template for displaying RSS2 Posts feed
   modified by the Professor to always show the FULL CONTENT - never the excerpt
   so that Firefox is forced to show the full content - as it should anyway */
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 bloginfo_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><![CDATA[<?php the_author() ?>]]></dc:creator>
		<?php the_category_rss('rss2') ?>
		<guid isPermaLink="false"><?php the_guid(); ?></guid>

                <!-- Replaced unwanted 'excerpt' code -->
                <description><![CDATA[<?php the_content_feed('rss2') ?>]]></description>
		<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>

		<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>
<?php }

I am posting this in the WordPress forum, so that others don't have to re-invent this themselves. Please comment if you find any mistakes or make any useful changes to my code.

---
Professor
This code is now being used in http://valentinesgiftsformen.professorsopportunities.com/


Viewing all articles
Browse latest Browse all 8245

Trending Articles