How to preserve HTML from posts in RSS feed

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 --
pThis is paragraph 1./p
!-- /wp:paragraph --

!-- wp:paragraph --
pIn a new paragraph, we begin an unordered list:/p
!-- /wp:paragraph --

!-- wp:list --
ullilist item 1/lililist item 2/lililist item 3/li/ul
!-- /wp:list --

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

!-- wp:html --
Begin custom HTML
brhra href=#link trial/abr
divpThis is a paragraph in a div/div
!-- /wp:html --

!-- wp:paragraph --
pEach/p
!-- /wp:paragraph --

!-- wp:paragraph --
pof/p
!-- /wp:paragraph --

!-- wp:paragraph --
pthese/p
!-- /wp:paragraph --

!-- wp:paragraph --
pwords/p
!-- /wp:paragraph --

!-- wp:paragraph --
pis/p
!-- /wp:paragraph --

!-- wp:paragraph --
pa/p
!-- /wp:paragraph --

!-- wp:paragraph --
pparagraph/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[pThis 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
pa href=https://domain.tld/sample/ rel=nofollowSource/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

Addendum: The end goal here is to enable MailChimp's RSS merge to pick up these posts and send them, collectively, in a periodic email without the need to duplicate efforts. I'm aware of the limitations of HTML in email, all posts will be extremely simple markup but I want at least to have paragraph breaks. I'm pretty sure my use case obviates using the API. With the markup being wrapped in CDATA I don't expect to run afoul of RSS validation.

.

Topic feed rss posts Wordpress

Category Web


Turns out that this behavior was being caused by a plug-in with a default setting to convert all posts into excerpts, thereby stripping the markup.

I determined this by standing up a stock WordPress instance with none of my customizations or theme, replicating the installed plug-ins (just their existence, not their settings), and checking the feed after activating each of them.

The moral of the story is that you'll miss a lot of behaviors and waste a lot of time tinkering with code and not focusing on replicating the behavior.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.