Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

_s: Simplifying search, index, and archive, with a common no posts fo…

…und template part, no-results.php; Closes #1187

git-svn-id: https://wpcom-themes.svn.automattic.com/_s/@9340 d957f892-c61d-0410-b221-f235e6eecf30
  • Loading branch information...
commit 7b04baa743ee6a179db8796cdb839179547f86de 1 parent 49f37d5
@ianstewart ianstewart authored
Showing with 37 additions and 29 deletions.
  1. +1 −10 archive.php
  2. +1 −9 index.php
  3. +34 −0 no-results.php
  4. +1 −10 search.php
View
11 archive.php
@@ -88,16 +88,7 @@
<?php else : ?>
- <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">
- <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 get_template_part( 'no-results', 'archive' ); ?>
<?php endif; ?>
View
10 index.php
@@ -38,15 +38,7 @@
<?php elseif ( current_user_can( 'edit_posts' ) ) : ?>
- <article id="post-0" class="post no-results not-found">
- <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 get_template_part( 'no-results', 'index' ); ?>
<?php endif; ?>
View
34 no-results.php
@@ -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
11 search.php
@@ -30,16 +30,7 @@
<?php else : ?>
- <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">
- <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 get_template_part( 'no-results', 'search' ); ?>
<?php endif; ?>
Please sign in to comment.
Something went wrong with that request. Please try again.