Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

martin.kreativermoment on "Strip Shortcodes from RSS"

$
0
0

Hi, I'm not sure if this is the right section.
If not not, please move.

I got this template to create my rss, but all shortcodes are shown in plaintext.

<?php
/*
Template Name: Custom Feed
*/

$numposts = 10;

function yoast_rss_date( $timestamp = null ) {
  $timestamp = ($timestamp==null) ? time() : $timestamp;
  echo date(DATE_RSS, $timestamp);
}

function yoast_rss_text_limit($string, $length, $replacer = '...') {
  $string = strip_tags($string);
  if(strlen($string) > $length)
    return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
  return $string;
}

$posts = query_posts('showposts=5');

$lastpost = $numposts -1;

header("Content-Type: application/rss+xml; charset=UTF-8");
echo '<?xml version="1.0"?>';
?><rss version="2.0">
<channel>
  <title></title>
  <link></link>
  <description></description>
  <language>de_DE</language>

<?php foreach ($posts as $post) { ?>

  <item>

    <title><?php echo get_the_title($post->ID); ?></title>
	    <link><?php echo get_permalink($post->ID); ?></link>
	<description><![CDATA[ <br /> ]]><?php echo '<![CDATA[' .get_the_post_thumbnail($post->ID, 'thumbnail') .']]>' ?><![CDATA[ <br /> ]]><?php echo '<![CDATA['.yoast_rss_text_limit($post->post_content, 500).'<br/><br/>Weiterlesen: <a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.']]>';  ?></description>
    <pubDate><?php yoast_rss_date( strtotime($post->post_date_gmt) ); ?></pubDate>
    <guid><?php echo get_permalink($post->ID); ?></guid>
  </item>

 <?php } ?>
</channel>
</rss>

Tried to use strip_shortcodes but I don't know where to place this. It dives me an empty page, or (on another position) it changes nothing.

Please help me out

Thanks


Viewing all articles
Browse latest Browse all 8245

Trending Articles