• I have this second query and I can’t use pagination as I am using another query before which extracts just one post from the same category but styled differently.

    Now, with the second query I use offset=1 so I won’t have the last post twice, therefore my WP-PageNavi doesn’t work as expected anymore.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    What I’ve done is to add an id to the containing div:

    id="<?php if ($wp_query->current_post < 1) echo "the-first-post"; ?>"

    And this applies that id which I can hide with CSS but the problem is, the first containing element from the second page gets, obviously, the same ID.

    Is there any possibility to make it somehow to apply the ID just once? This way I will get this pagination issue sorted. Or.. to apply the id IF the page doesn’t contain “page” in the URL? That might be the solution.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Chris Demetriad

    (@carlozdre)

    Maybe there’s someone else looking for the same thing so here’s how I’ve done it:

    <div class=”pages-thumbs” <?php if (false == strpos($_SERVER[‘REQUEST_URI’], ‘page’)) {

    if ($wp_query->current_post < 1) echo ‘id=”the-first-post”‘;

    } ?>>

    </div>

    If the URL contains “page” in the URL, this doesn’t apply that id to the div but if it doesn’t, the containing div gets the id=the-first-post”.

    is_paged() https://codex.www.ads-software.com/Function_Reference/is_paged

    if ($wp_query->current_post < 1 && !is_paged())

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Apply the ID to element from query_posts just once’ is closed to new replies.