Forums

[resolved] Selecting second-to-last latest post Query (3 posts)

  1. emzdesign
    Member
    Posted 2 years ago #

    Hi everyone,

    I'm working on a wordpress theme that requires an image slider at the top. As that involves JavaScript I've decided to use DIVS instead.

    I will have the latest post show, and 2 other posts in hidden divs. These divs will show when a user clicks on the arrow etc.

    I've done something like this before but without wordpress.

    Now I'm stuck, as I need 2 divs to be hidden so can't just pull the latest 3 posts out of the query.

    So, is there a way to pull out the second-to-last latest post? And the third?

    Sorry if that doesn't make any sense.

    The latest post I want to go into the main div. The second-to-last latest post I want to go in the first hidden div. And the third-to-last latest post I want to go in the second hidden div.

    If that makes any sense, please help.

    Thanks in advance.

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Could use 3 different queries and loops as exemplified in
    http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/

    Or couldn't you use a counter variable before your loop then an if statement in the loop that was

    $count=0
    while (have_posts()) : the_post(); // this may or may not be your loop
    $count++;
    if ($count == 1 ){
    //set div
    } elseif ($count == 2) {
    //set div
    } elseif ($count == 3) {
    //set div
    } else {
    //set div for everything else
    }
    // display posts stuff
    endwhile;
  3. Mark / t31os
    Moderator
    Posted 2 years ago #

    You could also take a look here for some ideas.
    http://www.upsidedowncity.net/wordpress-featured-post-slideshow/

    Hopefully it might be of some help...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags