Horje
Remove HTML from post content inside feed template page - Wordpress Solution
[Solved] - Remove HTML from post content inside feed template page - Wordpress Solution
Try following codes
Hey, I'm trying to create a custom feed template based on the original WordPress feed file. One important element of that feed is showing plain text (stripping image, video, and other html) post content. Also, it needs to display full post not an excerpt. I couldn't find any good resources that would help me accomplish this. So I would really appreciate your help guys. To make life easier, here's the file:
<?php
/**
 * RSS2 Feed Template for displaying RSS2 Posts feed.
 *
 * @package WordPress
 */

header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$more = 1;

echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	<?php do_action('rss2_ns'); ?>
>

<channel>
	<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
	<link><?php bloginfo_rss('url') ?></link>
	<description><?php bloginfo_rss("description") ?></description>
	<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
	<language><?php echo get_option('rss_language'); ?></language>
	<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
	<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
	<?php do_action('rss2_head'); ?>
	<?php 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><?php the_author() ?></dc:creator>
		<?php the_category_rss('rss2') ?>

		<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_option('rss_use_excerpt')) : ?>
		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
	<?php if ( strlen( $post->post_content ) > 0 ) : ?>
		<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
	<?php else : ?>
		<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
	<?php endif; ?>
<?php endif; ?>
		<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
		<slash:comments><?php echo get_comments_number(); ?></slash:comments>
<?php rss_enclosure(); ?>
	<?php do_action('rss2_item'); ?>
	</item>
	<?php endwhile; ?>
</channel>
</rss>
Thanks.

Solution - 1

Replace the in your code with the following one

<?php echo strip_tags(get_the_content_feed('rss2')); ?>


Solution - 2

Hello you can add an action to the_excerpt_rss() like this :

add_action( 'the_excerpt_rss', 'myfct' );
and myfct is :
function myfct( $content ) // $content not used because contains excerpt content
{
  global $post;
  return strip_tags( $post->post_content );
}
See you


Solution - 3

Have you checked out [[LINK href="http://pipes.yahoo.com"]]Yahoo! Pipes[[/LINK]]? That's what I use when taking a feed and editing the content. You can combine, filter, cut, truncate (and so much more) and then create a new rss feed from the original pretty easily. You can find walkthroughs for doing what you want online, too long to place here. Then you can take that rss feed and place it on your site or hook it up with a service like feedburner. I could probably build you one, too. Are you trying to edit your default feed to do this, though? Are you looking to build it into your wordpress blog as a plugin or native function? Yahoo Pipes might be easier and quicker to put together, but then it won't be native to your wordpress install. Pluses and minuses with that. If you want it to be native and effect your actual feed (instead of being a separate feed), then I would try Julio's answer.

Date: 2022-10-21 05:12:53
Category: Wordpress
More for You