1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Show Recent Posts Page?

Discussion in 'WordPress' started by Stu--, Apr 15, 2010.

  1. #1
    I am trying to add a new "page" which isn't a traditional wordpress page, but just shows a list of the recent posts in the same way as an archive page. I've tried making a file called recent.php but I don't know how to call it...

    Alternatively I'd be happy to program it into the archive page if I just knew how.

    What code do I need to show all the latest posts? Is there a url that can display these? Paging doesn't work for the recent posts code I'm currently using.

    <?php $recent = new WP_Query("cat=recent&showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
    Code (markup):
    I'm doing this for resourcebasedliving.com.
     
    Stu--, Apr 15, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    lukeg32, Apr 15, 2010 IP
  3. deluxdon

    deluxdon Catch Me If You Can...!!!™ Staff

    Messages:
    25,480
    Likes Received:
    1,943
    Best Answers:
    32
    Trophy Points:
    480
    #3
    Why don't you use Smart Archieve plugin for that to show seperate page for all posts month/date wise ?

    DON.
     
    deluxdon, Apr 15, 2010 IP
  4. Stu--

    Stu-- Active Member

    Messages:
    355
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Thanks but still no good. What I really just need is a way to paginate the most recent posts. I don't want to use a plugin. Surely this is a common need?
     
    Stu--, Apr 16, 2010 IP
  5. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #5
    I dont understand what the problem is.

    If you dont want to use a plugin, then get_post as linked above - or indeed query_posts will return the number of posts you ask for.

    Wordpress has its own pagination built into the query_posts function but will only show 'next' and 'previos' (or more/older posts, same thing). If this is not what you are after then you just need to build your pagination around the number of results vs the number of posts shown.
     
    lukeg32, Apr 16, 2010 IP
  6. Stu--

    Stu-- Active Member

    Messages:
    355
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Stu--, Apr 16, 2010 IP
  7. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #7
    Which just gives you 'next' posts links..... the exact same thing that query_posts does, as explained in my post.

    Why bother reinventing the wheel when wordpress does this for you already.... Given how much wordpress has changed since that was written, 2008, then are far simpler ways of doing it.
     
    lukeg32, Apr 16, 2010 IP