WordPress.org

Ready to get started?Download WordPress

Forums

confusion around is_paged (13 posts)

  1. RobLifford
    Member
    Posted 6 years ago #

    Why does is_paged not seem to apply to my first page of search results when there IS a "next page" link (for older search results) being generated? Seems to me like it really is paged, just not in both directions.

  2. whooami
    Member
    Posted 6 years ago #

    it is paged, and you can verify that by putting this:

    <?php if(is_paged) {echo "paged"; } ?>

    at the bottom of any template file to doublecheck.

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    "Paged" means everything but the first page. Only 2nd pages and onward are "paged".

  4. RobLifford
    Member
    Posted 6 years ago #

    Oh, weird -- I was testing it almost the same way and it wasn't working. I guess it was just syntax. I was using this:

    <?php if(is_paged() ) {
    echo('<h2>Test! This is paginated!</h2>');
    } ?>

    So I guess those extra parentheses were messing things up. Thanks.

  5. RobLifford
    Member
    Posted 6 years ago #

    Hmmm. Actually, I just noticed that the test code is showing up on search results or monthly archives that, at least from my perspective, aren't paged... like if there's only 3 posts to display and my max per page is 10. Am I still missing the concept? Does is_paged apply to things that _could be_ paged even if they aren't?

    My test code is exactly what whoomi provided above.

  6. whooami
    Member
    Posted 6 years ago #

    Well, I originally was going to respond as Otto did but decided to test it on my own site.. which i why I provided that, since that what I used to test :)

    My own site behaved as you have indicated -- the first page is, indeed, 'is_paged'.

    In fact, I even tested this scenario:

    http://www.xxx.org/archives/xxx/xxx/

    vs.

    http://www.xxx.org/archives/xxx/xxx/page/1/

    and they both show up as paged.

    I've edited those links, I really dont want my site spidered like that.

  7. whooami
    Member
    Posted 6 years ago #

    I got askimeted , Ive replied..

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Hmmm.. I didn't think that was the case. Weird.

    Is paged also set on single post pages (ones without the page tag, obviously) ? If so, then it's a bug and I may know the reason.

  9. RobLifford
    Member
    Posted 6 years ago #

    Otto42: yep, even on my single.php template, this code...

    <?php if(is_paged) echo "Paged!"; ?>

    ...*does* output Paged! in the HTML. Bug?

  10. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Probably. I need to setup a test site and see if I can figure out why it does that. I don't think it's supposed to.

  11. buechsengustl
    Member
    Posted 6 years ago #

    i've noticed that obviously there's a difference between is_paged and is_paged() (at least in wp 2.2), betwwen the variable and the function. you have to try out to find the right one for you, because i can't explain it ;)

  12. JeremyVisser
    Member
    Posted 6 years ago #

    I haven't tested this, but I'm guessing if(is_paged) is actually asking PHP "Is there a function called is_paged?" and PHP is saying "Yep, there's a function called is_paged".

  13. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Oh! Hah, yeah, Jeremy is correct, I never noticed that.

    The code *should* be if (is_paged())... like all those tags. If you leave those off, it's checking for existence of the function.

Topic Closed

This topic has been closed to new replies.

About this Topic