Advertisement
rexcoder

Search Page

Jan 5th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 KB | None | 0 0
  1. //Search Page---------------------------------------------------------------------------------------------
  2. <?php
  3. /**
  4.  * The template part for displaying a message that posts cannot be found.
  5.  *
  6.  * Learn more: http://codex.wordpress.org/Template_Hierarchy
  7.  *
  8.  * @package my-simone
  9.  */
  10. ?>
  11.  
  12. <section class="<?php if ( is_404() ) { echo 'error-404'; } else { echo 'no-results'; } ?> not-found">
  13.     <div class="index-box">
  14.     <header class="entry-header">
  15.         <h1 class="entry-title">
  16.                     <?php
  17.                     if ( is_404() ) { _e( 'Page not available', 'my-simone' ); }
  18.                     else if ( is_search() ) { printf( __( 'Nothing found for <em>', 'my-simone') . get_search_query() . '</em>' ); }
  19.                     else { _e( 'Nothing Found', 'my-simone' );}
  20.                     ?>
  21.                 </h1>
  22.     </header>
  23.  
  24.     <div class="entry-content">
  25.         <?php if ( is_home() && current_user_can( 'publish_posts' ) ) : ?>
  26.  
  27.             <p><?php printf( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', 'my-simone' ), esc_url( admin_url( 'post-new.php' ) ) ); ?></p>
  28.                        
  29.                 <?php elseif ( is_404() ) : ?>
  30.                        
  31.                         <p><?php _e( 'You seem to be lost. To find what you are looking for check out the most recent articles below or try a search:', 'my-simone' ); ?></p>
  32.                         <?php get_search_form(); ?>
  33.                        
  34.         <?php elseif ( is_search() ) : ?>
  35.  
  36.             <p><?php _e( 'Nothing matched your search terms. Check out the most recent articles below or try searching for something else:', 'my-simone' ); ?></p>
  37.             <?php get_search_form(); ?>
  38.  
  39.         <?php else : ?>
  40.  
  41.             <p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'my-simone' ); ?></p>
  42.             <?php get_search_form(); ?>
  43.  
  44.         <?php endif; ?>
  45.     </div><!-- .entry-content -->
  46.     </div><!-- .index-box -->
  47.    
  48.     <?php
  49.     if ( is_404() || is_search() ) {
  50.        
  51.         ?>
  52.     <header class="page-header"><h1 class="page-title">Most recent posts:</h1></header>
  53.     <?php
  54.         // Get the 6 latest posts
  55.         $args = array(
  56.             'posts_per_page' => 6
  57.         );
  58.  
  59.         $latest_posts_query = new WP_Query( $args );
  60.  
  61.         // The Loop
  62.         if ( $latest_posts_query->have_posts() ) {
  63.                 while ( $latest_posts_query->have_posts() ) {
  64.  
  65.                     $latest_posts_query->the_post();
  66.                     // Get the standard index page content
  67.                     get_template_part( 'content', get_post_format() );
  68.  
  69.                 }
  70.         }
  71.         /* Restore original Post Data */
  72.         wp_reset_postdata();
  73.  
  74.     }
  75.     ?>
  76.    
  77. </section><!-- .no-results -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement