• I was hoping someone could explain why TwentyThirteen calls content.php from index.php whereas page.php contains the loop? Also, why does index.php call content.php if there is no content to display:

    <?php if ( have_posts() ) : ?>
    
    			<?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
    			<?php endwhile; ?>
    
    			<?php twentythirteen_paging_nav(); ?>
    
    		<?php else : ?>
    			<?php get_template_part( 'content', 'none' ); ?>
    		<?php endif; ?>

    Thanks 🙂

Viewing 1 replies (of 1 total)
  • Hi physoc,

    page.php contains the loop, because there is no other place in Twenty Thirteen where this piece of code would get reused.

    If there is no content to display, index.php calls actually content-none.php. get_template_part()goes through a progression and looks for a file that is called like the combination of the two arguments, first in a possible child theme and then in the parent theme. If that file does not exist, it will look for a file that is called like the first argument. In our case it checks for the files like this:

    twentythirteenchild/content-none.php
    twentythirteen/content-none.php
    twentythirteenchild/content.php
    twentythirteen/content.php

    If there is content to display, we’d ask get_template_part() to look for a file that is called like the current post format (e.g. content-aside.php), and if it is not there serve content.php.

Viewing 1 replies (of 1 total)
  • The topic ‘TwentyThirteen calling content.php from index.php but not from page.php’ is closed to new replies.