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.
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.
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.
"Paged" means everything but the first page. Only 2nd pages and onward are "paged".
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.
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.
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.
I got askimeted , Ive replied..
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.
Otto42: yep, even on my single.php template, this code...
<?php if(is_paged) echo "Paged!"; ?>
...*does* output Paged! in the HTML. Bug?
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.
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 ;)
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".
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.
This topic has been closed to new replies.