1

I have a wordpress site and i have been working on it's feed. I noticed that when a post has been paginated with , it only renders the first page of the post. What i need to do is get all the content of the post and not just the first page.

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
$pub_date= mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);

......

$description = get_post(get_post_thumbnail_id())->post_content; // The Description
$content = get_the_content_feed('rss2'); 

Any advice?

1

If you are talking about paginated posts which created using <!--nextpage--> tag, then you will have to use the_content_feed hook to strip that tag and pass the full content. I have tried below code & it does exactly that. But please note it will pass full content to RSS feed for all the posts.

add_action('the_content_feed', 'strip_nextpage_tag_for_rss'); function strip_nextpage_tag_for_rss() { global $post; $content = apply_filters('the_content', $post->post_content); $content = str_replace( "\n<!--nextpage-->\n", '', $content ); $content = str_replace( "\n<!--nextpage-->", '', $content ); $content = str_replace( "<!--nextpage-->\n", '', $content ); $content = str_replace( "&lt;!--nextpage--&gt;", '', $content ); $content = str_replace( "<p>&lt;!&#8211;nextpage&#8211;&gt;</p>", '', $content ); $content = str_replace( "<p><!--nextpage--></p>", '', $content ); return $content; }

Place above code in your theme's functions.php file. I hope this helps.

7
  • I will test this out as soon as possible and accept your answer. I think this might really work. Thanks a lot :) – Kunal Oct 12 '15 at 11:38
  • You are welcome. Let me know if you face any problem ;-) – Prasad Nevase Oct 12 '15 at 15:35
  • I tried it but i can't seem to figure out how to use it... Could you please tell me? Don't i have to call that function somewhere? Thanks – Kunal Oct 12 '15 at 22:36
  • I saw your echo $content; but it outputs only the first page... i even tried str_replace but it doesn't work... – Kunal Oct 12 '15 at 23:40
  • You just need to place that code in functions.php file of your theme and you need not call the function. Once placed, visit your site /feed URL , ideally you shall see full page content for each post in the feed. Let me know how it goes. – Prasad Nevase Oct 13 '15 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.