• Okay, my problem is the RSS feed (https://akramsideas.com/feed/) for my site displays the post as one big paragraph, with no line breaks.

    I’ve searched the forums and the internet, and have found no solution for why this is happening.

    Originally, the feed seemed to be okay, as I would view it on my iPad from the bloglovin.com app. But the only change I’ve made since then is to add the function to enable thumbnails to my feeds.

    This is the function I added to the functions.php

    /* THUMBNAIL IN RSS FEED */
    function rss_post_thumbnail($content) {
    	global $post;
    
    	if(has_post_thumbnail($post->ID)) {
    		$content = '<p>' . get_the_post_thumbnail($post->ID) .
    		'</p>' . get_the_content();
    	}
    
    	return $content;
    }
    
    add_filter('the_excerpt_rss', 'rss_post_thumbnail');
    add_filter('the_content_feed', 'rss_post_thumbnail');

    I did find some information about the ![CDATA[ ] needing to be in your rss. When I view my rss https://akramsideas.com/feed/ the CDATA seems to be there, and the feed validates. Also, if the CDATA was the problem, what file would I edit to fix this, obviously not the functions.php, right?

    I also read that the paragraphs only work if your blog is set to display full text for feeds, which since I reinstalled WordPress on my server back in May, this option has always been set to full text.

    Lastly, I notice that on my feed https://akramsideas.com/feed/ there seems to a paragraph tag that surround both the thumbnail and entire content. Should this be there?

    Once again, my main issue is that my feed displays the entire post as a single paragraph, with no line breaks. What should I do to fix this.

    Thank you all in advance for any help on this matter.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Well described problem here!

    My guess would be that get_the_content behaves differently then the_content in terms of doing formatting filters. You can maybe search for the solution in this direction, like this blog.

    By the way you can also fix this problem by outputting the thumbnail just before the the_content tag instead of combining the content like this.

    Thread Starter Akram Taghavi-Burris

    (@taghaviburris)

    Thanks!
    I checked out the blog post you mentioned and it did the trick. I now have paragraph tags in the content of my rss feed.

    I did notice though that some readers still don’t show the formatting, for example the Sage extension in Firefox, but in Safari it seems to be just fine. It may just depend on the reader then, because the XML appears to be correct.

    This might also be attributed to the individual reader, but the captions to my images in the rss typically show up fine, while say for example in Sage extention for Firefox it displays with the caption tag around it like so:

    [caption id="attachment_1895" align="aligncenter" width="599"] Caption Text Here [/caption]

    Any ideas why this would happen?

    Oh, and I also notice in the XML there is an unmatched paragraph tag before the content, I just wonder where it is coming from. We’ll at least the main paragraph issue is resolved.

    This is what I ended up putting in my functions.php

    /*FORMAT get_the_content WITH PARAGRAPHS*/
    function get_the_content_with_formatting ($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    	$content = get_the_content($more_link_text, $stripteaser, $more_file);
    	$content = apply_filters('the_content', $content);
    	$content = str_replace(']]>', ']]>', $content);
    	return $content;
    }
    
    /* THUMBNAIL IN RSS FEED */
    function rss_post_thumbnail($content) {
    	global $post;
    
    	if(has_post_thumbnail($post->ID)) {
    		$content = '<p>' . get_the_post_thumbnail($post->ID) .
    		'</p>' . get_the_content_with_formatting();
    	}
    
    	return $content;
    }
    
    add_filter('the_excerpt_rss', 'rss_post_thumbnail');
    add_filter('the_content_feed', 'rss_post_thumbnail');

    In my experience with E-readers I would just go for outputting valid and correct XML RSS-feeds and let readers do whatever they want since there is so much difference between all of them ?? Of course be sure to support the one that are most used with your reader base.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘RSS Feed no paragraphs in content’ is closed to new replies.