Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Question is clear I guess.

Normally, which template is returned when no search results are found. I would say search.php, but my parent theme's (twenty thirteen) search.php looks like this (slightly edited):

<?php if ( have_posts() ) : ?>

    <header class="page-header">
        <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentythirteen' ), get_search_query() ); ?></h1>
    </header>

    <?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; ?>

So, what is the none after content in the third last line? What exactly is fetched from content.php then?

share|improve this question
1  
no-results.php template was initially used for this purpose. In the recent versions of WordPress (as of Twenty Thirteen theme), it was moved into content-none.php for consistency. –  its_me Oct 13 '13 at 10:27

1 Answer 1

up vote 2 down vote accepted

get_template_part( 'content', 'none' ); will look for:

  1. content-none.php
  2. content.php

Twenty Thirteen does have content-none.php.

In general this is organized in such way to support dynamic lookups where first two-part template might or might not exist and fallback to more generic template, if necessary.

share|improve this answer
    
Thanks. Completely looked over content-none.php! –  Bram Vanroy Sep 14 '13 at 11:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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