How to preserve HTML from posts in RSS feed

Question

I have set up a sample post with a few different HTML tags. This is the markup, copied from the block editor:

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:paragraph -->
<p>This is paragraph 1.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In a new paragraph, we begin an unordered list:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>list item 1</li><li>list item 2</li><li>list item 3</li></ul>
<!-- /wp:list -->

<!-- wp:image {"id":418,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://domain.tld/wp-content/uploads/2018/11/logo.png" alt="" class="wp-image-418"/><figcaption>organization logo</figcaption></figure>
<!-- /wp:image -->

<!-- wp:html -->
Begin custom HTML
<br><hr><a href="#">link trial</a><br>
<div><p>This is a paragraph in a div</div>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Each</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>of</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>these</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>words</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>is</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>a</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>paragraph</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

Checking on my feed, it shows description and content:encoded elements like the following:

<description><![CDATA[This is an excerpt]]></description>
<content:encoded><![CDATA[<p>This is paragraph 1. In a new paragraph, we begin an unordered list: list item 1 list item 2 list item 3 Begin custom HTML link trial This is a paragraph in a div Each of these words is a paragraph...</p>
<p><a href="https://domain.tld/sample/" rel="nofollow">Source</a></p>]]></content:encoded>

Obviously some mechanism is stripping all the HTML and wrapping the plaintext of the post in a single <p> – but I’m struggling to find what it is.

I placed a print_debug_backtrace() at the top of feed-rss2.php and got the following:

#0  require_once() called at [/home1/foo/public_html/wp-includes/template.php:770]
#1  load_template(/home1/foo/public_html/wp-includes/feed-rss2.php) called at [/home1/foo/public_html/wp-includes/functions.php:1623]
#2  do_feed_rss2() called at [/home1/foo/public_html/wp-includes/class-wp-hook.php:305]
#3  WP_Hook->apply_filters(, Array ([0] => ,[1] => rss2)) called at [/home1/foo/public_html/wp-includes/class-wp-hook.php:327]
#4  WP_Hook->do_action(Array ([0] => ,[1] => rss2)) called at [/home1/foo/public_html/wp-includes/plugin.php:470]
#5  do_action(do_feed_rss2, , rss2) called at [/home1/foo/public_html/wp-includes/functions.php:1585]
#6  do_feed() called at [/home1/foo/public_html/wp-includes/template-loader.php:48]
#7  require_once(/home1/foo/public_html/wp-includes/template-loader.php) called at [/home1/foo/public_html/wp-blog-header.php:19]
#8  require(/home1/foo/public_html/wp-blog-header.php) called at [/home1/foo/public_html/index.php:17]

I have also set up a custom debug page and stepped through what I observed as the call stack of the <content:encoded> element. Those tests all came back with the desired HTML and none of the WP content comments.

Appreciate any help you all can send my way.

0
paneerakbari 2 weeks 2021-10-04T16:04:20-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse