Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kclimson

macrumors newbie
Original poster
Aug 15, 2011
28
0
Canada
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(); ?>
 
Last edited by a moderator:

nuxx

macrumors member
Jun 5, 2007
80
3
Tokyo
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.
 
Last edited:

kclimson

macrumors newbie
Original poster
Aug 15, 2011
28
0
Canada
Help out :3

At a cursory glance it looks like you're code's missing
Code:
while(have_posts())

The display of the search results needs to be in a loop otherwise it'll only print the first result.

If this will fix the problem where do I place it?
 

nuxx

macrumors member
Jun 5, 2007
80
3
Tokyo
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">
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.