I changed up my theme to work what I think is the "proper" way. After reading in the codex and seeing things on this site.

I started from scratch. loaded the 2012 theme. Made two pages. Home and blog. I set the homepage to have the default 2012 front-page.php template. then in the settings->reading I set static front page to home and posts page to blog. I know the posts will be pulled from the index.php so in that file, I put the custom loop to pull from the blog category and in my front-page.php file I put a custom loop to get pages.

 $args = array(
    'post_type' => 'page'

  $page_query = new WP_Query( $args );

  if ( $page_query->have_posts() ) : while ( $page_query->have_posts() ) :   $page_query->the_post();
  $template = get_post_meta( $post->ID, '_wp_page_template', true );
  // If the page doesn't have any template assigned - display the default page template
    if ( $template == 'default') { ?>

    <div class="title"><?php the_title();?></div>
            <?php the_content(); ?>
    <?php   }  else {
        include( $template );

This loop was working just fine in other versions of this theme but for some reason, set up the way it is now which is suppose to be the right way, it's not working. I also tried using pre_get_posts to display pages on the front-page. ?>

  • 1
    I don't understand your code. This is from front-page.php? So you are looping through pages, checking the assigned template, and if that template is not default, you are trying to include the template - is that right? Templates are not intended for inclusion, they represent the overall structure of a page. Also, including front-page.php within front-page.php would lead to infinite inclusions - that is, if you could simply include a template, which you cannot, as the path to that file is not complete.
    – vancoder
    Apr 18, 2013 at 23:35
  • You can include templates because I have done it. It just won't work the way it is set up right now. The code above is in front-page.php. I am trying to get the pages to show in that. For some reason it won't work. When I was doing the include, I just put in some code to say that if it was the homepage template then don't include that one.
    – Jamie
    Apr 19, 2013 at 3:01
  • 1
    I don't understand why you are attempting to do things like this. WordPress should do most of this work for you according to the template hierarchy.
    – s_ha_dum
    Apr 19, 2013 at 3:23
  • I am trying to do it because I am trying to make a one page WordPress site. I am trying to do it based on template hierarchy but it doesn't work. I fixed the issue above but now my issue is that it won't display the templates. It only displays the page content
    – Jamie
    Apr 19, 2013 at 3:42

1 Answer 1


I fixed part of my issue by setting the "posts_per_page" => -1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.