How do I get Wordpress to include recent posts in a page?

I have the home page going to a static page. The static page just gives general information about the site. I'd like to have recent post summaries or at least links to them after the static content on that page. Is there a painless way to do this?

4 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    No pain, no gain... they say. I don't believe them!! :)

    Basically you need a WP loop. Sounds very technical, but in fact it is a matter of "copy" and "paste".

    First, in the Wordpress theme editor you must find the page template you want to show the recent posts.

    Then, find the place where you want the recent posts to show.

    Copy and paste this code for the recent posts to show with title and content:

    <?php $my_query = new WP_Query('showposts=10');

    while ($my_query->have_posts()) : $my_query->the_post(); ?>

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    <?php the_content(the_title('', '', false)); ?>

    <?php endwhile; ?>

    or

    Copy and paste this code for the recent posts to show with title:

    <?php $my_query = new WP_Query('showposts=10');

    while ($my_query->have_posts()) : $my_query->the_post(); ?>

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    <?php endwhile; ?>

    What the code does:

    1. Create a wordpress loop that will search for the latest 10 posts in your database and extract them

    2. Put on your page the title and content for the first example and only the title for the second example for the latest 10 posts

    You can replace "<h2>" and "</h2>" with any tag if you want to format it or if you think that h2 would influence your SEO

    Hope you can manage from here. Don't hesitate to contact me for further detailing

    Source(s): Wordpress Themes: http://tntbase.com
  • 1 decade ago

    No really "painless" way to do it. Basically, you want to make a Page Template for your static page, then to put a new Loop on it, after the main one. This new Loop will use a new WP_Query call, to get the recent posts and display what you want.

    More info can be found on the WordPress Codex and in the WordPress support forums.

  • Laura
    Lv 4
    4 years ago

    Okay, cool. I just tried it.. and that code is not excluding any categories from the index.php ( <?php wp_list_categories('exclude=1,3,5,7'); ?> ) I am suppose to put it in the index.php, and make my home page 'recent posts', right? (i am kira, in a different account.)

  • 1 decade ago

    Try searching the plugins database

Still have questions? Get your answers by asking now.