Adding Additional Archived Content in Search Results (Archive Posts)
-
My WordPress site search results are working great. I’m attempting to add a list of archived posts along with a “We didn’t find anything! You might want to check out the following articles:” when the search results come back with no results.
I’ve created two loops (at least I think I have!) that are working fine but the “no results + archived posts” are still appearing in the regular search results – I only want them to appear in the “No Results” results.
Any suggestions?
Here’s my code:
// <!– Main Search Results –>
<div id=”front” class=”primary_col”><?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count == 1) : ?><div id=”featured”>
<div class=”thumbnail”>
<?php the_post_thumbnail( ‘single-post-thumbnail’ ); ?>
</div><div class=”title”>
<h2><?php the_category(‘, ‘); ?><i> — <?php the_time(‘l, F j, Y’); ?></i></h2>
<h1>” title=”<?php the_title(); ?>”><?php the_title(); ?></h1></div>
</div><?php else : ?>
<div class=”clearandspace”></div>
<div class=”otherposts”>
<div class=”thumbnail”><?php the_post_thumbnail(); ?></div>
<div class=”contents”>
<h3>” title=”<?php the_title(); ?>”><?php the_title(); ?></h3>
<h2><i><?php the_time(‘l, F j, Y’); ?></i></h2>
</div>
</div><?php endif; ?>
<?php endwhile; ?><div class=”clearandspace”></div>
<div class=”navigation”>
<div class=”alignleft”><?php posts_nav_link(”,”,’Previous Entries’) ?><?php posts_nav_link(”,’Next Entries’,”) ?></div>
</div><!– Alternate Search Results – With Posts –>
<?php else : ?>
<div class=”clearandspace”></div><h1>We didn’t find anything!</h1>
<p>Try narrowing your search term. If that doesn’t seem to work, please make a request HERE</p>
<div class=”dash”></div>
<h3>You might want to check out the following articles:</h3>
<div class=”dash”></div><?php endif; ?>
<div class=”clearandspace”></div>-
<?php query_posts(‘showposts=’.get_option(‘gp_archives_articles’)); ?><?php while (have_posts()) : the_post(); ?>
<li class=”archives”>
<div class=”thumbnail-medium”><?php the_post_thumbnail(); ?></div>
<span class=”title”>” title=”<?php the_title(); ?>”><?php the_title(); ?></span>
<span class=”meta”><?php the_time(‘l, F j, Y’); ?> – #comments” title=”Jump to the comments”><?php comments_number(‘0 Comments’,’1 Comment’,’% Comments’); ?></span><?php endwhile; ?>
<!– // Search Results –>
Thanks!
- The topic ‘Adding Additional Archived Content in Search Results (Archive Posts)’ is closed to new replies.