title: Problem return a function inside of a shortcode in Wordpress
body: <p>I have some trouble coding a themes shortcode. I want the code to display a div with a view counter function, and then a link with the shotcodes content as the url.</p>
  <p>The view_count(); function works fine when called inside theme files, and I actually managed to make it show, but then it displayed before the_content(); of the post (the gray bar), when I wanted it within content under an element.</p>
  <p>(1) Here's what I've got:</p>
  <pre><code>function video_block( $atts, $content = null ) { 
      return '&lt;div class=&quot;video-block&quot;&gt;&lt;span class=&quot;ViewCount&quot;&gt;&lt;?php the_views(); ?&gt;&lt;/span&gt; &lt;a class=&quot;dl-source&quot; href=&quot;' . $content . '&quot;&gt;Link&lt;/a&gt;&lt;/div&gt;';
  }
  </code></pre>
  <p>(2) Here's the code that displays both on top of page:</p>
  <pre><code>function video_block( $atts, $content = null ) { ?&gt;
      &lt;div class=&quot;video-block&quot;&gt;&lt;span class=&quot;ViewCount&quot;&gt;&lt;?php the_views(); ?&gt;&lt;/span&gt; &lt;a class=&quot;dl-source&quot; href=&quot;&lt;?php echo $content; ?&gt;&quot;&gt;Link&lt;/a&gt;&lt;/div&gt;
  &lt;?php }
  </code></pre>
  <p>(3) This code displays the views above content, and the link in the correct place:</p>
  <pre><code>function video_block( $atts, $content = null ) {
      $views = the_views();
      return '&lt;div class=&quot;video-block&quot;&gt;&lt;span class=&quot;ViewCount&quot;&gt;&lt;?php $views; ?&gt;&lt;/span&gt; &lt;a class=&quot;dl-source&quot; href=&quot;&lt;?php echo $content; ?&gt;&quot;&gt;Link&lt;/a&gt;&lt;/div&gt;';
  }
  </code></pre>
  <p>I read somewhere in the Wordpress forums that you should return (instead of echo) values within functions, but that breaks it, displaying the view count, skips the  html and spits out the $content.</p>
  <p>Here is a link to the page in question: <a href="http://nvrt.me/4Qf1" rel="nofollow noreferrer">http://nvrt.me/4Qf1</a> (currently using code from block #2)</p>
  <p>I'm running out of midnight oil. I would really appreciate it if someone could help me out.</p>
  <hr />
  <p><strong>EDIT:</strong></p>
  <p>Here is the code for the_views(); function. I can see that it's echoed, but when changed to return, it doesn't display it at all.</p>
  <pre><code>### Function: Display The Post Views
  function the_views($display = true, $prefix = '', $postfix = '', $always = false) {
      $post_views = intval(post_custom('views'));
      $views_options = get_option('views_options');
      if ($always || should_views_be_displayed($views_options)) {
          $output = $prefix.str_replace('%VIEW_COUNT%', number_format_i18n($post_views), $views_options['template']).$postfix;
          if($display) {
              echo apply_filters('the_views', $output);
          } else {
              return apply_filters('the_views', $output);
          }
      }
      elseif (!$display) {
          return '';
      }
  }
  </code></pre>