Forums

Loop ignores "Show at most:" days setting (4 posts)

  1. shoshanna
    Member
    Posted 4 years ago #

    I have this loop on my page:

    <?php
    	   if (is_home()) {
    		  query_posts("cat=2");
    	   }
    	?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				 <!-- <small><?php the_time('F jS, Y') ?> by <?php the_author() ?></small> -->
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<!--<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>-->
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></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 include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>

    In Options > Reading, I can change the number of posts shown and it displays correctly on the page.

    When I change the number of days shown, though, it doesn't work. The number of posts that shows up on the page does change, but it doesn't seem to have anything to do with the actual dates that they were posted: if I enter 30 days in the admin, posts that are older than 30 days are still there. Is there something I need to change in my loop to get this to work correctly?

    We'll be upgrading soon, but I'd like to fix this first if I can. Thanks!

  2. MichaelH
    Volunteer
    Posted 4 years ago #

    The "number of days" feature never worked if I remember.

    In fact later versions do away with that setting.

    Recommend you upgrade to at least version 2.0.11.

  3. shoshanna
    Member
    Posted 4 years ago #

    Thanks, we were going to upgrade anyway but now I know to do that first!

  4. Otto
    Tech Ninja
    Posted 4 years ago #

    Also note that this:
    query_posts("cat=2");

    Will break the paging. You need to change that to this:
    query_posts($query_string.'&cat=2');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.