How to keep HTML in feed items content?
π Note: This solution provided in this article is for the Feedzy widget, not for the imported posts feature.
Some feeds have HTML tags for the content or other elements. If you want to keep them, then this tutorial will help you.
- 1
-
Copy the following code snippet.
- 2
-
Paste it into the child theme's function.php or to a site-specific plugin.
- 3
-
Make sure you replace the list of feeds with the desired feed.
πNote: Do not remove HTML tags from the summary and/or use the item content instead of its description.
function tifd_summary_input( $description, $content, $feedURL ) { //If you want to use the item content as the description. If not, then remove this line //If feed don't have content meta, $content is already equal to $description $description = $content; //List of feeds you don't want to remove HTML tags $feedList = array ( 'http://www.gumdust.com/feed', 'http://b-website.com/feed' ); //Remove the item HTML tags (as in the default hook) if not in the above list if( !in_array( $feedURL, $feedList ) ) { $description = trim( strip_tags( $description ) ); } //Remove hellip (as in the default hook) //Keep in mind that it will be added later in the plugin render $description = trim( chop( $description, '[…]' ) ); return $description; } add_action( 'init', 'feedzy_summary_input_remove', 99 ); function feedzy_summary_input_remove() { remove_filter('feedzy_summary_input', array( Feedzy_Rss_Feeds::instance()->get_admin(), 'feedzy_summary_input_filter' ), 9); } add_filter( 'feedzy_summary_input', 'tifd_summary_input', 10, 3 );
π‘ Example
We have used an RSS feed that contained tables. Before using the code snippet, the description was delivered on the same line without taking into consideration the existing table. After using the code snippet, the table is displayed as expected.