WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Latest Post, No Category, Multiple loops (3 posts)

  1. Nate
    Member
    Posted 3 years ago #

    I understand that I can have 2 loops in my blog with one calling a specific category at the top of the page which acts like the latest post.

    That's not what I want.

    What I would prefer to happen is have the Latest Post(loop 1) get a style which is different from the other posts(loop 2) without calling a specific category. Once I make a new post it replaces the 2nd most recent post which then get's pushed to the 2nd loop without being duplicated.

    Another way to explain it. Only the most recent post at the top of the page receives it's own unique style without having to assign a specific category to it while making the post.

    Does anyone know of a script or plugin which can help me achieve this?

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    no need for two lops, this can work with a conditional statement;

    try this kind of structure:

    $new = 'first';
     while( have_posts() ) : the_post(); //start the loop
    
    if( $new == 'first' && !is_paged() ) :
    $new = 'not-first';
    /*how to style the first post; html and all*/
    else:
    /*how to style all other posts; html and all*/
    endif;
    
    endwhile; //end of the loop
  3. Nate
    Member
    Posted 3 years ago #

    Alchymyth

    Works flawlessly. Thank you ever so much. PM if you need a graphic artist for anything, free of course. <3

Topic Closed

This topic has been closed to new replies.

About this Topic