• Resolved Odenberg

    (@murmelin)


    I want to show the 5 latest posts on my front (static) page as a complement to my News section with the regular post feed.

    How do I code it?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Why not just set the home page in Settings > Reading to show the main blog page and set it to show 5 posts?

    Otherwise… query_posts

    If you want to combine it with your regular blog page I’d just use a recent posts widget in the sidebar, I assume it’s for a specific category? otherwise Jonas point is well taken.

    Thread Starter Odenberg

    (@murmelin)

    I want a special landing page instead of the regular blog. The 5 most recent posts is only to be shown as title and image on the landing page and then link to the full posts.

    Shall look in to the query_posts…

    Sounds like you may only need to change “the_excerpt” to “the_content” in your archive.php template. Sometimes this is set in the main loop.php, or “loop-archive.php”

    If you do this, your category archives will show full content instead of excerpts.

    Thread Starter Odenberg

    (@murmelin)

    Thanks for your answer.

    The thing is that I need two separate loops. One on a static frontpage that shows only title and featured image of the 5 latest posts. Since I also have a regular blogpage that shows the full post, categories, I need to have an extra loop on the front page.

    Try the plugin “xili Posts in Posts”. It creates a seperate loop to querry posts. Highly configurable, includes shortcode, template tag and widget.

    Be sure to get “xili posts in posts” and not “posts in posts”, not sure about that one, although it may do the same.

    Thread Starter Odenberg

    (@murmelin)

    Thanks everyone!
    I figuered it out. It was acually very easy. What I did was:

    1. I created a separate page template called ‘Start Page’ and first in the document I put:
    <?php
    /*
    Template Name: Start_Page
    */
    ?>

    2. I put the regular Loop in the page, just as usual.

    3. Then I put this code:
    <?php query_posts(‘showposts=5’); ?>
    Just before the Loop.

    So you get 2 seperate loops in your home page, one as per admin settings, the other with the show posts code above? nice! Is there a way to specify a category? or does it just duplicate the first 5 posts in the main loop?

    Thread Starter Odenberg

    (@murmelin)

    Yes, I got two loops. One regular blog loop showning 10 posts/page (set in admin) and one extra loop on a page that shows the title and featured image of the 5 latest posts.

    To specify category, add:

    &category_name=xxx

    right after =5 in my example above

    Nice work!

    can I see?

    Thread Starter Odenberg

    (@murmelin)

    When Im finished with the site. Hopefully in about a week ??

    Look forward to seeing it, and thanks for the solution, I know I’ll use this.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Add latest Posts on a static Page’ is closed to new replies.