title: Shortcode displaying shortcode and not content
body: <p>Im using "insert pages" plugin for wordpress that allows me to insert pages and posts into other pages and posts from the backend. My problem being that when i i use "insert pages" plugin in my news section and then visit the site it shows the shortcode instead of the content. This seems to be a problem only when making a "post". If i use the plugin to display a page within another page it works fine (shows the content not the shortcode).</p>
  
  <p>Any idea what could be the cause of this problem?</p>
  
  <p>Cheers,
  Emil</p>
  
  <p>Update</p>
  
  <pre><code>// Shortcode hook: Replace the [insert ...] shortcode with the inserted page's content
      function insertPages_handleShortcode_insert( $atts, $content = null ) {
          global $wp_query, $post, $wp_current_filter;
          extract( shortcode_atts( array(
                      'page' =&gt; '0',
                      'display' =&gt; 'all',
                  ), $atts ) );
  
          // Validation checks.
          if ( $page === '0' ) {
              return $content;
          }
  
          // Trying to embed same page in itself.
          if ( $page == $post-&gt;ID || $page == $post-&gt;post_name ) {
              return $content;
          }
  
          // Don't allow inserted pages to be added to the_content more than once (prevent infinite loops).
          $done = false;
          foreach ( $wp_current_filter as $filter ) {
              if ( 'the_content' == $filter ) {
                  if ( $done ) {
                      return $content;
                  } else {
                      $done = true;
                  }
              }
          }
  
          // Get page object from slug or id
          $temp_query = clone $wp_query; // we're starting a new loop within the main loop, so save the main query
          $temp_post = $wp_query-&gt;get_queried_object(); // see: http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_2
  
          // Convert slugs to page IDs to standardize query_posts() lookup below.
          if ( ! is_numeric( $page ) ) {
              $page_object = get_page_by_path( $page, OBJECT, get_post_types() );
              $page = $page_object ? $page_object-&gt;ID : $page;
          }
  
          if ( is_numeric( $page ) ) {
              $args = array(
                  'p' =&gt; intval( $page ),
                  'post_type' =&gt; get_post_types(),
              );
          } else {
              $args = array(
                  'name' =&gt; esc_attr( $page ),
                  'post_type' =&gt; get_post_types(),
              );
          }
  
          query_posts( $args );
  
          // Start our new Loop
          while ( have_posts() ) {
              ob_start(); // Start output buffering so we can save the output to string
  
              // Show either the title, link, content, everything, or everything via a custom template
              // Note: if the sharing_display filter exists, it means Jetpack is installed and Sharing is enabled;
              // This plugin conflicts with Sharing, because Sharing assumes the_content and the_excerpt filters
              // are only getting called once. The fix here is to disable processing of filters on the_content in
              // the inserted page. @see https://codex.wordpress.org/Function_Reference/the_content#Alternative_Usage
              switch ( $display ) {
              case "title":
                  the_post(); ?&gt;
                  &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
                  &lt;?php break;
              case "link":
                  the_post(); ?&gt;
                  &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
                  &lt;?php break;
              case "excerpt":
                  the_post(); ?&gt;
                  &lt;h1&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;
                  &lt;?php if ( has_filter( 'the_content', 'sharing_display' ) ) echo get_the_excerpt(); else the_excerpt(); ?&gt;
                  &lt;?php break;
              case "excerpt-only":
                  the_post(); ?&gt;
                  &lt;?php if ( has_filter( 'the_content', 'sharing_display' ) ) echo get_the_excerpt(); else the_excerpt(); ?&gt;
                  &lt;?php break;
              case "content":
                  the_post(); ?&gt;
                  &lt;?php if ( has_filter( 'the_content', 'sharing_display' ) ) echo get_the_content(); else the_content(); ?&gt;
                  &lt;?php break;
              case "all":
                  the_post(); ?&gt;
                  &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
                  &lt;?php if ( has_filter( 'the_content', 'sharing_display' ) ) echo get_the_content(); else the_content(); ?&gt;
                  &lt;?php the_meta(); ?&gt;
                  &lt;?php break;
              default: // display is either invalid, or contains a template file to use
                  $template = locate_template( $display );
                  if ( strlen( $template ) &gt; 0 ) {
                      include $template; // execute the template code
                  } else { // Couldn't find template, so fall back to printing a link to the page.
                      the_post(); ?&gt;
                      &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;?php
                  }
                  break;
              }
  
              $content = ob_get_contents(); // Save off output buffer
              ob_end_clean(); // End output buffering
          }
          wp_reset_postdata();
          $wp_query = clone $temp_query; // Restore main Loop's wp_query
          $post = $temp_post;
  
          $content = "&lt;div data-post-id='$page' id='insertPages_Content'&gt;$content&lt;/div&gt;";
          return $content;
          //return do_shortcode($content); // careful: watch for infinite loops with nested inserts
      }
  </code></pre>