Found posts is part of the WP_Query Object…
As you said it simply holds the value of the total results..
All you need to know should be here.
http://codex.ww.wp.xz.cn/Function_Reference/WP_Query
Is there something in particular you need to know?
Thread Starter
ckruse
(@ckruse)
Mostly just curious. I recently wrote my own pagination script which was obviously more then it needed to be. I found this property and it solved all my problems. On my index page I was limiting the number of posts shown to 5 (showposts=5), but I wanted, at the bottom with the pagination to display the total number of pages, like PAGE 1 OF 10. So I stored the query request
$theQuery = $wp_query->request;
Then I stripped the LIMIT from that request, as it was limiting to 5. Then re-ran the query without the limit for the sole purpose of getting the total number of posts based on my query. A lot of work and database stuff for nothing.
I did not realize the wp_query object had that property stored.
Plonk this in one of your template files…
print '<pre>';
print_r($wp_query);
print '</pre>';
Will give you plenty of info about what’s stored in wp_query…
That’s what i did before posting the link, was quicker to do as i already had the editor and local install open on my screen…
*bump*
I have a plugin which uses the following piece of code:
$this->found_posts = (int)$wp_query->found_posts;
But i want to exclude a category, how can i adjust that “$wp_query” thingy? It isn’t set in the plugin it’s self.
The plugin is for “pagination”. And the problem is, the plugin sees more posts becuz i used the “posts system” to post “portfolio items” which are not shown in the weblog itself.