Wordpress Search.php question?

Discussion in 'Web Design and Development' started by kclimson, Mar 16, 2012.

  1. kclimson, Mar 16, 2012
    Last edited by a moderator: Mar 16, 2012

    kclimson macrumors newbie

    kclimson

    Joined:
    Aug 15, 2011
    Location:
    Canada
    #1
    Hey, I own a blog. Whenever I search something on it in the search bar I only get one result. Anybody know why? Here's an example http://www.macview.ca/?s=Diablo.
    The code for the search.php is below.

    PHP:
    <?php get_header(); ?>


       <div id="primary" class="grid_15">
       <div class="InformationBar">
      <h4 class="TopNews"> iPad 3 released on March 7th </h4>
      
      
       </div>
                





    <?php $posts=query_posts($query_string .
    '&posts_per_page=15'); ?>         
    <?php if (have_posts()) : ?>
          





    <div class="PUSHHH">

    <div class="thumbnail">
    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    <img src="http://macview.ca/wp-content/themes/MacView.ca/timthumb.php?src=<?php echo catch_that_image() ?>&w=140&h=105&zc=1">
    </a>
    </div>



    <a class="titlesearch" href="<?php the_permalink() ?>" rel="bookmark" 
    title="Permanent Link to <?php the_title_attribute(); ?>">
    <?php the_title(); ?></a>

    <div>

    <a class="textunderneath"><?php the_time('l jS F, Y - g:ia'?> <?php $author get_the_author(); ?> </a>
    <a class="searchcomments" href="<?php comments_link(); ?>"><?php comments_number'no responses''one response''% responses' ); ?> </a>
     

    </div> 
    </div>



          
          
          <div class="navigation">
     <div class="alignleft">

    <p class="alignleft2"><?php next_posts_link('Continue reading'?> </p> </div>

    <div class="alignright">

    <p class="alignright2"><?php previous_posts_link('Newer posts'?> </p> </div> 

     </div>
    <?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that
             isn't here.</p>
          <?php get_search_form(); ?>
       <?php endif; ?>         
                
                
                
                
                
                
                
                
    <?php get_sidebar(); ?>

    <?php get_footer(); ?>
     
  2. nuxx, Mar 16, 2012
    Last edited: Mar 16, 2012

    nuxx macrumors member

    nuxx

    Joined:
    Jun 5, 2007
    Location:
    Tokyo
    #2
    At a cursory glance it looks like your code's missing
    PHP:
    while(have_posts())
    The display of the search results needs to be in a loop otherwise it'll only show the first result.
     
  3. kclimson thread starter macrumors newbie

    kclimson

    Joined:
    Aug 15, 2011
    Location:
    Canada
    #3
    Help out :3

    If this will fix the problem where do I place it?
     
  4. nuxx macrumors member

    nuxx

    Joined:
    Jun 5, 2007
    Location:
    Tokyo
    #4
    Replace

    PHP:
    <?php if (have_posts()) : ?>
    with

    PHP:
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>

    Add

    PHP:
    <?php endwhile; ?>
    immediately before the line

    PHP:
    <div class="navigation">
     
  5. kclimson thread starter macrumors newbie

    kclimson

    Joined:
    Aug 15, 2011
    Location:
    Canada
    #5

    You just saved me :D See how it works now, when you search something at www.macview.ca :3
     

Share This Page