title: How to include a file in shortcode function in wordpress
body: <p>I want to make a shortcode and in shortcode i want to require a file. when a user write a shortcode in editor. The output will show the required file layout.</p>
  
  <p>I make a shortcode but this not working, here is my shortdoe Code:</p>
  
  <pre><code>&lt;?php
      function inner_page( $atts, $content = null ){
      $return_string = require 'foo/foo_artilces_list.php';
  
      return $return_string;
      }
  
      add_action('init', 'register_section_shortcodes');
      function register_section_shortcodes(){
          add_shortcode('inner_page', 'inner_page');
      }
  ?&gt;
  </code></pre>
  
  <p>Here is my require file code</p>
  
  <pre><code>&lt;?php
       /*=========
      Template Name: KBE
   =========*/
  
       get_header();
  ?&gt;
  
  &lt;div id="foo_container"&gt;
  
      &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
  
      &lt;!--Breadcrum--&gt;
      &lt;?php
          if(FOO_BREADCRUMBS_SETTING == 1){
      ?&gt;
          &lt;div class="foo_breadcrum"&gt;
              &lt;?php echo foo_breadcrumbs(); ?&gt;
          &lt;/div&gt;
      &lt;?php
          }
      ?&gt;
      &lt;!--/Breadcrum--&gt;
  
      &lt;!--search field--&gt;
      &lt;?php
          if(FOO_SEARCH_SETTING == 1){
      ?&gt;
          &lt;div class="foo_search_field"&gt;
              &lt;input name="" type="text" placeholder="Search the knowledgebase..." /&gt;
          &lt;/div&gt;
      &lt;?php
          }
      ?&gt;
      &lt;!--/search field--&gt;
  
      &lt;!--content--&gt;
  &lt;?php
      if(FOO_SIDEBAR_SETTING == 0){
  ?&gt;
      &lt;div id="foo_content" class="foo_content_full" &gt;
  &lt;?php
      }
      elseif(FOO_SIDEBAR_SETTING == 1){
  ?&gt;
      &lt;div id="foo_content" class="foo_content_right" &gt;
  &lt;?php
      }
      elseif(FOO_SIDEBAR_SETTING == 2){
  ?&gt;
      &lt;div id="foo_content"&gt;
  &lt;?php
      }
  ?&gt;
          &lt;!--leftcol--&gt;
          &lt;div class="foo_leftcol"&gt;
  
              &lt;div class="foo_categories"&gt;
          &lt;?php
              $foo_cat_args = array(
                  'orderby'       =&gt; 'term_order', 
                  'order'         =&gt; 'ASC',
                  'hide_empty'    =&gt; true, 
              );
  
              $foo_terms = get_terms(FOO_POST_TAXONOMY, $foo_cat_args);
  
              foreach($foo_terms as $foo_cat){
                  $foo_term_id = $foo_cat-&gt;term_id;
                  $foo_term_slug = $foo_cat-&gt;slug;
                  $foo_term_name = $foo_cat-&gt;name;
          ?&gt;
                  &lt;div class="foo_category"&gt;
                      &lt;h2&gt;
                          &lt;span class="foo_count"&gt;&lt;?php echo FOO_ARTICLE_QTY; ?&gt; Articles&lt;/span&gt;
                          &lt;a href="&lt;?php echo get_term_link($foo_term_slug, 'foo_cat') ?&gt;" title="&lt;?php 
  
  sprintf( __( "View all posts in %s" ), $foo_term_name ) ?&gt;"&gt;&lt;?php echo $foo_term_name; ?&gt;&lt;/a&gt;
                      &lt;/h2&gt;
  
                      &lt;ul class="foo_article_list"&gt;
                  &lt;?php
                      $foo_tax_post_args = array(
                          'post_type' =&gt; FOO_POST_TYPE,
                          'posts_per_page' =&gt; FOO_ARTICLE_QTY,
                          'orderby' =&gt; 'name',
                          'order' =&gt; 'ASC',
                          'tax_query' =&gt; array(
                              array(
                                  'taxonomy' =&gt; FOO_POST_TAXONOMY,
                                  'field' =&gt; 'slug',
                                  'terms' =&gt; $foo_term_slug
                              )
                          )
                      );
  
                      $foo_tax_post_qry = new WP_Query($foo_tax_post_args);
  
                      if($foo_tax_post_qry-&gt;have_posts()) :
                          while($foo_tax_post_qry-&gt;have_posts()) :
                              $foo_tax_post_qry-&gt;the_post();
                  ?&gt;
                              &lt;li&gt;
                                  &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;
                                      &lt;?php the_title(); ?&gt;
                                  &lt;/a&gt;
                              &lt;/li&gt;
                  &lt;?php
                          endwhile;
                      else :
                          echo "No posts";
                      endif;
                  ?&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
          &lt;?php
              }
          ?&gt;
              &lt;/div&gt;
  
          &lt;/div&gt;
          &lt;!--/leftcol--&gt;
  
          &lt;!--aside--&gt;
          &lt;?php
              if((FOO_SIDEBAR_SETTING == 2) || (FOO_SIDEBAR_SETTING == 1)){
                  dynamic_sidebar('foo_cat_widget');
              }
          ?&gt;
          &lt;!--/aside--&gt;
      &lt;/div&gt;&lt;!--content--&gt;
  
  &lt;/div&gt;
  
  &lt;?php
      get_footer();
  ?&gt;
  </code></pre>
  
  <p>It show me only widgets and all layout get messy.
  any idea</p>