_s: Simplifying search, index, and archive, with a common no posts found template part, no-results.php; Closes #1187

git-svn-id: https://wpcom-themes.svn.automattic.com/_s/@9340 d957f892-c61d-0410-b221-f235e6eecf30
This commit is contained in:
Ian Stewart 2012-03-29 15:55:33 +00:00
parent 49f37d5920
commit 7b04baa743
4 changed files with 37 additions and 29 deletions

View File

@ -88,16 +88,7 @@ get_header(); ?>
<?php else : ?> <?php else : ?>
<article id="post-0" class="post no-results not-found"> <?php get_template_part( 'no-results', 'archive' ); ?>
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', '_s' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', '_s' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?> <?php endif; ?>

View File

@ -38,15 +38,7 @@ get_header(); ?>
<?php elseif ( current_user_can( 'edit_posts' ) ) : ?> <?php elseif ( current_user_can( 'edit_posts' ) ) : ?>
<article id="post-0" class="post no-results not-found"> <?php get_template_part( 'no-results', 'index' ); ?>
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'No posts to display', '_s' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php printf( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', '_s' ), admin_url( 'post-new.php' ) ); ?></p>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?> <?php endif; ?>

34
no-results.php Normal file
View File

@ -0,0 +1,34 @@
<?php
/**
* The template part for displaying a message that posts cannot be found.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package _s
* @since _s 1.0
*/
?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', '_s' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<?php if ( is_home() ) { ?>
<p><?php printf( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', '_s' ), admin_url( 'post-new.php' ) ); ?></p>
<?php } elseif ( is_search() ) { ?>
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', '_s' ); ?></p>
<?php get_search_form(); ?>
<?php } else { ?>
<p><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', '_s' ); ?></p>
<?php get_search_form(); ?>
<?php } ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->

View File

@ -30,16 +30,7 @@ get_header(); ?>
<?php else : ?> <?php else : ?>
<article id="post-0" class="post no-results not-found"> <?php get_template_part( 'no-results', 'search' ); ?>
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', '_s' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', '_s' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?> <?php endif; ?>