Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Are you following the Codex guidelines for search results pages?
http://codex.wordpress.org/Creating_a_Search_Page
Now i guess the page search.php is working, but the posts not is showing… Only appears: Search Results for: “search”…
Is there anything wrong with my code?
<?php
/*
Template Name: Search Page
*/
?>
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<h3 class="page-title"><?php printf( __( 'Search Results for: %s', 'mytheme' ), '<span>' . get_search_query() . '</span>' ); ?></h3>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else : ?>
<div class="container">
<div class="row-fluid">
<div class="span8">
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'No results found', 'mytheme' ); ?></h1>
</header>
<div class="entry-content">
<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'mytheme' ); ?></p>
</div>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<div class="span4 pull-right">
<?php get_sidebar(); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>