2

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?

1

1 Answer 1

3

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.

1
  • Thanks. Completely looked over content-none.php! Sep 14, 2013 at 11:53

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.