WordPress.org

Ready to get started?Download WordPress

Forums

Displaying most recent posts in 2 parts (4 posts)

  1. WandererPSU
    Member
    Posted 4 years ago #

    I have a site design where the 3 newest posts are featured, and then farther down the page after other content I have an "Other Posts" section that I want to show the 7 next posts that chronologically follow the 3 featured posts.

    Basically newest post 1-3 are one part of the site, while posts 4-10 are somewhere else on the page. Is there any easy way to do this? Any help would be appreciated.

    Thanks

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

  3. vtxyzzy
    Member
    Posted 4 years ago #

    I am guessing that you have two different div's for the two sections. If so, something like this should work:

    $counter = 0;
    while (have_posts()) :
       ++$counter;
       if ($counter == 1) {
          // Start the first div
       } elseif ($counter > 3) {
          // End the first div
          // Start the second div
       }
       // Rest of the loop
    endwhile;
    // End the second div
  4. vtxyzzy
    Member
    Posted 4 years ago #

    After thinking about this for a while, I believe this will work while the outline I posted earlier will not:

    $counter = 0;
    while (have_posts()) :
       ++$counter;
       if ($counter == 1) {
          // Start the first div
       } elseif ($counter == 4) {
          // End the first div
          // Start the second div
       }
       // Rest of the loop
    endwhile;
    if ($counter > 0) {
       // End the first/second div
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.