• Hi!

    I want to create a new page on my site and when folks click on it on the header it should automatically go to ‘Older Posts’.

    What’s the best way to do this?

    Thanks in advance!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    More or less sure what you’ve deemed as Older Posts (like 10 days old or more?) but it basically sounds like you want an archives.php page. Here’s an example of code I use for my archive of posts in a listed format displaying each post title, grouped by month :

    <?php
    $recentposts = get_posts('orderby=date&numberposts=-1');
    $m = $o = '';
    
    foreach ($recentposts as $post) :
    	setup_postdata($post);
    	if ($m != get_the_time('m')) { $m = get_the_time('m');
    		if (($m != $o) && ($o != '')) { echo '		</ul>'."\n"; } ?>
    
    		<h2 class="archive-title"><a href="/<?php the_time('Y/m'); ?>/"><?php the_time('F Y'); ?></a></h2>
    		<ul>
    <?php	} else { $o = $m; } ?>
    			<li>
    				<div class="date"><?php the_time('j') ?></div>
    				<h4><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h4>  (<?php comments_number(0, 1, '%', 'comments-link', '-'); ?>)
    			</li>
    
    <?php endforeach; ?>
    		</ul>

    It will list all posts (“numberposts=-1”) from the most recent one to the oldest one (“orderby=date”) . You can configure the page to not display, for example the 10 latest posts, by adding “offset=10” to the arguments sent by get_posts();

    In your “Older Posts” page, assign it a page template that includes the above code.

    I hope this is what you were looking for.

    Thread Starter mpuri

    (@mpuri)

    Thanks gotax, I’ll check it out!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘New page ==> ‘Older Posts’’ is closed to new replies.