tags:

views:

23

answers:

1

Apparently the following simple code breaks the shortcode API of wordpress. When I add this code in the function.php the shortcode API won't work. This code is normally to add a text at the bottom of each page, any idea why?

function cmstut_basic_promote($content)
{
 echo $content;
 if(is_single())
 {
 ?>
 <div class="promote">
  <h2>Enjoy this article?</h2>
  <p>If you have enjoyed this article please subscribe to our <a href="<?php bloginfo('rss2_url'); ?>">RSS Feed</a></p>
 </div>
 <?php
 }
}
add_filter('the_content', 'cmstut_basic_promote');
+1  A: 

you must return the content from your filter not echo it - so something like

function cmstut_basic_promote($content) {
   if(is_single()) {
      return $content . '<div class="promote"><h2>Enjoy this article?</h2> ...';
   } else {
      return $content;
   }
}

would be the way to go

roman
yep, thanks :D just starting with wordpress plugin
krike