[wp-hackers] wp_count_posts() vs $found_posts

Kevin Ladenheim kplad21230 at yahoo.com
Fri Sep 14 13:16:39 UTC 2012


Hello,

On a vanilla Wordpress site the code at the bottom of this post works fine. 

$published_posts always equals $query->found_posts

On a site with many plugins $published_posts is correct and nonzero but
$query->found_posts is always zero and no posts are ever returned.

Does anyone have any tips for troubleshooting this type of problem? Is
it likely that a plugin is clobbering something?


?php
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
?>

<?php $query = new WP_Query( 'post_status=publish' ); ?>
<?php print "Blog posts: $query->found_posts"; ?><br>
<?php print "Published posts: $published_posts"; ?><br>

Thanks,

Kevin 



More information about the wp-hackers mailing list