title: Include custom post type in Wordpress loop
body: <p>Sorry, I think I read every post about this but cant get it to work.</p>
  
  <p>I have a Wordpress custom post typ called "external" and I would like to show both the post from "external" aswell as my normal standard posts at the same time on my homepage.</p>
  
  <p>This is my loop:</p>
  
  <pre><code>&lt;?php 
  get_header(); 
  
  if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
  elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
  else { $paged = 1; }?&gt;
  
  
  &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
  &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(''); ?&gt;&gt;
      &lt;?php the_content(); ?&gt;
  &lt;/div&gt;
  &lt;?php endwhile; wp_reset_postdata(); endif; ?&gt;    
  </code></pre>
  
  <p>How can I include the "external" posts in this code?</p>
  
  <p>The theme then uses blocks to display content on the startpage, here is block8.php with a post query. </p>
  
  <pre><code>function block_eight_ajax_query($atts='') {
      $args = array (
  $is_ajax = 0;
  if($atts==''){
      $is_ajax=1;
      $atts=$_GET;
      if($atts['global_query']){
          unset($atts['no_found_rows']);
          unset($atts['suppress_filters']);
          unset($atts['cache_results']);
          unset($atts['update_post_term_cache']);
          unset($atts['update_post_meta_cache']);
          unset($atts['nopaging']);
      }
  }
  $atts['is_ajax'] = $is_ajax;
  $query = null;
  $query = new WP_Query( $atts );
  $html = '';
  if ( $query-&gt;have_posts() ) {
      ob_start();
      $i = 1;
      while ( $query-&gt;have_posts() ):
          $query-&gt;the_post();
  
          $atts['video'] = rd_field( 'abomb_post_video' );
          $atts['extern'] = rd_field( 'extern' );
          $atts['audio'] = rd_field( 'abomb_post_audio' );
          $atts['gallery'] = rd_field( 'abomb_post_gallery' );
          $atts['counter'] = $i;
          block_grid_content($atts);
          if ($atts['column'] == 'grid-12') { $divide = 1; }
          else if ($atts['column'] == 'grid-3') { $divide = 4; }
          else if ($atts['column'] == 'grid-4') { $divide = 3; }
          else { $divide = 2; }
          if ($i%$divide==0 &amp;&amp; $divide!=1) {
              echo '&lt;div class="clear"&gt;&lt;/div&gt;';
          }
          $i++;
      endwhile;
      if ($atts['nav'] == 'numbered') {
          echo '&lt;div class="grid-12"&gt;';
              rd_pagination($query-&gt;max_num_pages);
          echo '&lt;/div&gt;';
      }
      wp_reset_postdata();
      $html = ob_get_clean();
      if($is_ajax==1){
          echo $html;
          exit();
      }
      return $html;
  }
  else{
      if($is_ajax==1){
          echo '-11';
          exit();
      }
      return '';
  }
  }
  </code></pre>
  
  <p>Update: I added this code to functions:</p>
  
  <pre><code>add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
  
  
  function add_my_post_types_to_query( $query ) {
  if ( $query-&gt;is_home() &amp;&amp; $query-&gt;is_main_query() )
      $query-&gt;set( 'post_type', array( 'post', 'extern' ) );
  return $query;
  }
  </code></pre>
  
  <p>Now I can see the posts in for exampel the search result but I need the Query in Block8.php to fetch them aswell.</p>
  
  <p>I Thanks!</p>