Results 1 to 3 of 3

 

Thread: Wordpress search results page help needed

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Feb 2009
    Location
    Lancashire
    Posts
    297
    Thanks
    64
    Thanked 35 Times in 21 Posts


    How do I stop the message "No results could be found matching the search you entered, please check your spelling." appearing when there are results found, which is what is happening on a site I'm building.

    Code:
    <?php get_header(); ?>
    <div id="col-wrapper">
    <div id="left-col">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>           
    <div <?php post_class(); ?>>
    <div class="postarea">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>            
    <?php the_content("Read More & Compare Prices >"); ?>               
    <div class="clear"></div>                               
    <?php require(TEMPLATEPATH . '/includes/post-meta-block.php'); ?>
    </div>        
    </div>                
    <?php endwhile; else: ?>                   
    <?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?>
    <?php endif; ?>          
    <div class="postarea">
    <h2>Sorry</h2>
    <p>No results could be found matching the search you entered, please check your spelling.</p>         
    <?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?>
    </div>
    </div>
    <div id="right-col">    			
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    </div>
    </div>
    <?php get_footer(); ?>
    I do want the message to display if no results are found.

    Paul

  2. #2
    scriptmonkey's Avatar
    Oranges & Lemons

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Worthing
    Posts
    1,607
    Thanks
    112
    Thanked 253 Times in 192 Posts
    Simpy move the para <p>No results could be found matching the search you entered, please check your spelling.</p> from outside the "while - else - end" loop into the loop

    So, move it to above the first instance of <?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?> then it will do what you want.

  3. The Following User Says Thank You to scriptmonkey For This Useful Post:

    macnpaul (02-04-10)

  4. #3
    Registered User

    Status
    Offline
    Join Date
    Feb 2009
    Location
    Lancashire
    Posts
    297
    Thanks
    64
    Thanked 35 Times in 21 Posts
    Thanks scriptmonkey, works perfectly.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Wordpress posts on non-wordpress page
    By paraleadogg in forum Programming
    Replies: 9
    Last Post: 17-03-10, 01:26 PM
  2. How does Wordpress-Google know which page is my home page?
    By Seamaster in forum Getting Started in Affiliate Marketing
    Replies: 7
    Last Post: 19-02-10, 01:55 PM
  3. How wordpress posts are shown in google search results
    By monty in forum Affiliate Marketing Lounge
    Replies: 9
    Last Post: 14-04-08, 04:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2