• Is there a way to show the last post completely and below that the excerpts of the five (or so) following posts on the frontpage?

Viewing 15 replies - 1 through 15 (of 22 total)
  • Yes.
    Before the loop you need to do a query_posts:
    <?php query_posts('posts_per_page=1'); ?>
    After the loop you would do a get_posts:
    <ul>
    <?php
    $posts = get_posts('numberposts=6&offset=1');
    foreach ($posts as $post) :
    ?>
    <li><a href=\"<?php the_permalink(); ?>\"><?php the_title() ?></a><?php the_excerpt(); ?></li>
    <?php
    endforeach;
    ?>
    </ul>

    Where the numberofposts in the get_posts is the number of excerpts you want, plus the number of posts per page (1+5 in this example). So, if you wanted the 3 most recent posts, plus 5 excerpts, you would change the posts_per_page in the query_posts to 3, and change the number postsperpage in the get_posts to 8 and the offset to 3.

    One correction to miklb’s reply: You don’t need to compensate for the offset parameter in get_posts. If you want 5 post (excerpts) offset by 1, just use:

    get_posts('numberposts=5&offset=1')

    Kafkaesqui-I was mistaken. Thanks.

    So do you not need the query_posts when using the get_posts?

    You do for the initial post if Options > Reading is not set to 1 post per page. I think most would not wish to change this just to alter the home page display.

    Thread Starter yurimaanzand

    (@yurimaanzand)

    It works!
    Thanks guys – i’m a php-nitwit so this was very helpful.

    Thread Starter yurimaanzand

    (@yurimaanzand)

    Ok – me again.
    How do i show the complete post?
    I mean, i now have the latest post, followed by several excerpts, but is it possible to make the latest post override the ‘more’-command, so that is completely visible?

    Is the <!--more--> in the post? Are you using the default theme or some elses? That theme may be using the_excerpt instead of the_content inside the loop.

    Thread Starter yurimaanzand

    (@yurimaanzand)

    Yes, the <!–more–> is in every post. So actually i am searching for a way to override the <!–more–> tag for the last post.
    I am using my own theme, based on two or three others, but my index.php (or actually my home.php for the frontpage) is using the_content(__(‘(more…)’)); inside the loop…

    I get what you’re trying to do here, but you realize it’s like asking for an automatic locking door to never automatically lock except for when you want it to automatically lock…

    To *defeat* the more link you have to work around it, and that means replacing the_content() with some other method of displaying post content. A quick way to do this is to echo $post->post_content, but this leaves out any formatting WordPress takes care of. So to do things right, you want to wrap the formatting/conversion functions around $post->post_content, like the following:

    <?php
    echo wptexturize(convert_smilies(convert_chars(wpautop($post->post_content))));
    ?>

    Looks complicated, but takes care of (I believe all) the formatting features built into WordPress that act on post content.

    Note this will bypass WordPress’ filtering API. If you have any plugins that work with post content, you would need to add their functions into that nested group above (ech).

    What file needs to be modified in order to have the excerpts show up period?

    I have added a couple of excerpt plugins, unfortunately I have no idea how to use them.

    Thread Starter yurimaanzand

    (@yurimaanzand)

    Thanks Kafkaesqui!
    That trick works fine. I don’t have any plugins on the post content, so this is exactly what i need. My blog is here if you would like to see the result. (it’s in dutch)

    Thread Starter yurimaanzand

    (@yurimaanzand)

    And here i am again…
    Seems that i do have a plugin on the post content – the lazy-images plugin to be precise…
    I found it here: http://davidseah.com/projects/lzil

    How should i add that function to the nested group as suggested by Kafkaesqui?

    There appear to be two separate functions in that plugin to be called as filters. Try:

    <?php
    echo
    LazyImagePre(
    LazyImagePost(
    wptexturize(
    convert_smilies(
    convert_chars(
    wpautop(
    $post->post_content
    ))))));
    ?>

    (Note I broke up the code into lines for readability, but either this way, or as one line like above, will work.)

    Thread Starter yurimaanzand

    (@yurimaanzand)

    Thanks again!

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘Only last post, then excerpts?’ is closed to new replies.