Forums

Different latest post with other posts (Query Question) (4 posts)

  1. seedpxwee5
    Member
    Posted 3 years ago #

    Right now all my posts in my index page are excerpts
    I want to query the latest post and make it function with the <!--more--> tag.
    How do I query the first post and put the condition ?

    I want it to be like
    <?php while (have_posts()) : the_post(); {
    if query_post(latest post)
    the_content();
    else
    the_excerpt();
    } ?>

    I think the query part is wrong though. I have no idea which to use. Any help here ?

  2. stvwlf
    Member
    Posted 3 years ago #

    if i understand what you are asking for, you need two loops.

    display the full content of the 1st post

    <?php query_posts('showposts=1');
    while (have_posts()): the_post(); ?>
       <?php the_content(); ?>
    <?php endwhile; ?>

    display excerpts from all the other posts - skip the first post (offset = 1)

    <?php query_posts('offset=1');
    while (have_posts()): the_post(); ?>
       <?php the_excerpt(); ?>
    <?php endwhile; ?>
  3. seedpxwee5
    Member
    Posted 3 years ago #

    What does showpost=1 means ?
    Does that means the latest post?

    So if I put showpost=2 or showpost=3 or showpost=4
    Does that means 2nd latest, 3rd latest and 4th latest ?

  4. stvwlf
    Member
    Posted 3 years ago #

    showposts means the number of posts to show

    it starts at the latest one by default

    offset=1 means to skip the first one

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.