WordPress.org

Forums

How do I list the 5 most recent posts? (24 posts)

  1. barbarac
    Member
    Posted 10 years ago #

    How do I list the 5 most recent posts in my sidebar? I've been looking at the control panel and can't see an optiion for it.

    Rob

  2. Kafkaesqui

    Posted 10 years ago #

  3. Avenir
    Member
    Posted 10 years ago #

    Wouldn't <?php wp_get_archives('type=postbypost&limit=5'); ?> list the five most recent posts?

  4. lawtai
    Member
    Posted 10 years ago #

    yea it would, even this would work:

    <?php get_archives('postbypost', '10'); ?>

    just change 10 to 5.

  5. tarpon
    Member
    Posted 10 years ago #

    This

    <?php get_archives('postbypost', '10'); ?>

    Worked great.

    Gotta love the WP community, makes customizing your site a breeze.

  6. Root
    Member
    Posted 10 years ago #

    The thing is a lot of plugins have been overtaken by the new built in funtionality.

  7. soupenvy
    Member
    Posted 10 years ago #

    No way to not display current archive, huh?

    For example - for use on single.php template, only display other recent posts, not the current one.

  8. Erwin
    Member
    Posted 10 years ago #

    Can you, using <?php get_archives('postbypost', '10'); ?>, also use variables? E.g. I'd like to show the author too, is that possible?

  9. sskhalsa
    Member
    Posted 10 years ago #

    Yes the code is great, but how do you get it to correctly follow the theme of your site? Ive tried i, but it looks out of place on my sidebar. For example, the entries are not bulleted and the background of its section on the sidebar is not white like the rest of the sidebar entries!

    Anyone know how to fix that?

  10. sskhalsa
    Member
    Posted 10 years ago #

    since u cant edit posts on this site ill tell u my fix lol

    make sure u add

      and
    and put the code in there, then it keeps everything

  11. sskhalsa
    Member
    Posted 10 years ago #

    oops

    < ul > and < /ul >

  12. cyberkamote
    Member
    Posted 10 years ago #

    yea it would, even this would work:

    <?php get_archives('postbypost', '10'); ?>

    just change 10 to 5. -----

    Where will I paste this code?

  13. nicholaswong
    Member
    Posted 9 years ago #

    cyberkamote:

    Just post somewhere you want in sidebar.php

  14. stephanie
    Member
    Posted 9 years ago #

    I wonder if this would work for getting the last number of comments as well?

  15. Kafkaesqui

    Posted 9 years ago #

    To display last N comments you'll have to roll your own code, or use a plugin:

    http://codex.wordpress.org/Plugins/Comments

  16. nohea
    Member
    Posted 9 years ago #

    How do I also list the 5 or 10 most recent posts in a sidebar while skipping the posts already present and being viewed on the frontpage with this tag ?

    Thanks for any help. :)

  17. zedikia
    Member
    Posted 9 years ago #

    If i'm displaying it on another page in a different directory on the site, how would i do that?

    for exaple: WP is installed at jmwproductions.com/blog but i want to display the post titles at jmwproductions.com/index_new.php in a table cell.

  18. moshu
    Member
    Posted 9 years ago #

    I don't think you can do it on a .html file. You need a .php file to make it work easy.

  19. zedikia
    Member
    Posted 9 years ago #

    that's fine. i can easily make it into a php file.

  20. moshu
    Member
    Posted 9 years ago #

    If you promise to not double post in the future, I'll give you the solution :)

    Make that "index_new.php" file "WP-aware"...
    Put this at tyhe top of the file, before everything else:
    <?php
    require('./path-to-your-blog/wp-blog-header.php');
    ?>

    After that you can use any WP function in the file.

    Another option, less demanding on the DB would be to use the RSS feeds with a feedreader (search for it)

  21. zedikia
    Member
    Posted 9 years ago #

    that worked. thanks a ton. didn't mean to dbl post. thanks moshu.

  22. VhailorZ
    Member
    Posted 8 years ago #

    ok if this is a noob question, sorry, but i added the code to display the latest 5 posts, but theres a huge open line between each line of text (post). It looks something likt this:

    recent posts
    post 1

    post 2

    how do i get it to display (without the line break):

    recent posts
    post 1
    post 2

    this is the code i used: <?php get_archives('postbypost', '10'); ?>

    thanks for any help!! :)

  23. jamshed
    Member
    Posted 8 years ago #

    Thanks alot working fine :D

    regards,
    http://www.pakdir.net

  24. shimon
    Member
    Posted 8 years ago #

    I tried <?php wp_get_archives('type=postbypost&limit=5'); ?> and it did not work-it still shows more than 5. My site is http://www.mutabletech.com . Any suggestions?

Topic Closed

This topic has been closed to new replies.

About this Topic