WordPress.org

Forums

[resolved] Customizing post listing pages that follow the initial post listing page. (5 posts)

  1. hsatterwhite
    Member
    Posted 6 years ago #

    I was wondering if there is a way to make an exception to the loop that will let you apply custom styles to any post listing pages that come after the first/main post listing page?

    For example the initial listing page for a category will have one look and than all of the pages for older/previous entries will have an alternative style/look to them.

    Thanks :)

  2. esmi
    Forum Moderator
    Posted 6 years ago #

  3. hsatterwhite
    Member
    Posted 6 years ago #

    Ok, so I could run a conditional to check if the post listings are paged, but how would I pragmatically distinguish the first listing page from the ones that follow, so that the initial page has a different layout and the following pages are uniform?

    Thanks for the link. I'm going to read more in to that function itself.

  4. Mark / t31os
    Moderator
    Posted 6 years ago #

    Firstly you use something like this to setup the paged variable..

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 0 ;
    ?>

    Once you have that, you know the first page is 0...
    So..

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 0 ;
    if($paged == 0) {
    // It's the first page do something
    }
    elseif($paged == 1) {
    // It's the next page
    }
    else {
    // It's any pages other then the first or second
    }
    ?>

    You don't necessarily need to do lots of IF/ELSE, you could use a switch....

  5. hsatterwhite
    Member
    Posted 6 years ago #

    Spot on! Simple and easy. Yea a switch might be faster depending on how expanded this gets.

    Thanks so much for the help t310s and esmi :)

Topic Closed

This topic has been closed to new replies.

About this Topic