earlier posts link with wp_query

Discussion in 'WordPress' started by sixrfan, Mar 16, 2011.

  1. #1
    on this page i'm using the following code to pull in the 25 most recent posts from category 4.

    
    <?php
    $custom_query = new WP_Query( 'posts_per_page=25&cat=4' );
    if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    
    <hr class="homenews" />
    
    <?php endwhile; else : ?>
    <h3>Sorry...</h3>
    No posts were found.
    
    <?php next_posts_link('&laquo; Older Entries') ?>
    
    <?php endif; ?>
    
    Code (markup):
    but how do i add a link at the bottom of the page that says "click here for earlier posts", and leads to a page that lists the 25 items posted before that???

    please advise. thanks in advance.
     
    sixrfan, Mar 16, 2011 IP
  2. dsimi

    dsimi Member

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Try in custom page template.

    1. Make a php file recentposts.php like below

    <?php
    /*
    Template Name: 25 Recent posts
    */
    ?>
    <?php get_header( ); ?>
    Your custom code for 25 posts
    <?php get_sidebar();?>
    <?php get_footer(); ?>

    2. Goto "Add New Page" in wp admin page. Then create new page with select the template name "25 Recent posts" in right side template selection dropdown.

    3. Make a link manually in footer.php (for add a link in bottom of the site)
    <a href="your newly created custom template link page">click here for earlier posts</a>
     
    dsimi, Mar 16, 2011 IP