Support » Fixing WordPress » 1 post on index followed by 10 recent title: Possible?

  • Hello,

    Is there a way to have 1 main post on the front page followed by 10 recent titles so it looks a little like this,

    Latest Title
    some text here and so on.

    01:05:2005 – title here
    01:05:2005 – title here
    01:05:2005 – title here
    01:05:2005 – title here
    01:05:2005 – title here
    and so on.

    Can it be done?

    Thanks
    F

Viewing 4 replies - 1 through 4 (of 4 total)
  • First, create a home.php for your theme. Just make a copy of index.php and name it home.php.

    Then, replace The Loop in home.php with this:

    <?php
    // First post
    $posts = get_posts('numberposts=1');
    foreach ($posts as $post) :
    setup_postdata($post);
    ?>

    <!– Place here any template tags/html/etc. you want to in The Loop for your latest post. Based on your query: –>

    <h3 class="post-title"><?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_content(); ?>

    <?php endforeach;
    // Next ten posts
    get_posts('numberposts=10&offset=1');
    foreach ($posts as $post) :
    ?>

    <?php the_time('m:d:Y'); ?> - <a href="<?php the_permalink(); ?>"><?php the_title() ?></a>

    <?php endforeach; ?>

    -------------------------------------

    Info on the get_posts function:

    http://wiki.wordpress.org/get_posts

    (Note that ‘category’ is supported in 1.5.)

    Thank you so muc Kafkaesqui 🙂

    Just what I wanted.
    F

    Technically that works, but it causes the Loop to be run twice and an extra page to be created – not always desirable.

    When I needed to do this, I just modified the index.php to set bIsFirstPost = true at the top, then changed the Loop to show the_content if that value is true, and the_excerpt if the value is false. Of course, you have to set bIsFirstPost = false at the end of the Loop 😉

    Doing it this way means home.php is available for something else and the Loop is only run once.

    Hi RustIndy,

    I might be interested in that.

    Have you any code examples? Can’t quite get my head around what you do 🙂

    Thanks
    Karl

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘1 post on index followed by 10 recent title: Possible?’ is closed to new replies.