admin管理员组文章数量:1395312
I have a seach page in which am showing results based on keyword and custom category search. Issue i am facing is that, I need to display the count of results. I had referred the wordpress documentation and found some codes, for eg :
<h2 class="pagetitle">Search Result for <?php
/* Search Count */
$allsearch = &new WP_Query("s=$s&showposts=-1");
$key = wp_specialchars($s, 1);
$count = $allsearch->post_count;
_e('');
_e('<span class="search-terms">');
echo $key;
_e('</span>');
_e(' — ');
echo $count . ' ';
_e('articles');
wp_reset_query();
?></h2>
But this displays the total search results and I need results count filtered by found in the specified category
I have a seach page in which am showing results based on keyword and custom category search. Issue i am facing is that, I need to display the count of results. I had referred the wordpress documentation and found some codes, for eg :
<h2 class="pagetitle">Search Result for <?php
/* Search Count */
$allsearch = &new WP_Query("s=$s&showposts=-1");
$key = wp_specialchars($s, 1);
$count = $allsearch->post_count;
_e('');
_e('<span class="search-terms">');
echo $key;
_e('</span>');
_e(' — ');
echo $count . ' ';
_e('articles');
wp_reset_query();
?></h2>
But this displays the total search results and I need results count filtered by found in the specified category
Share Improve this question edited Jun 6, 2012 at 7:52 Eugene Manuilov 11.4k4 gold badges44 silver badges50 bronze badges asked Jun 6, 2012 at 6:31 user930026user930026 1431 gold badge2 silver badges12 bronze badges 1 |1 Answer
Reset to default 0Have you tried wp_count_posts ? http://codex.wordpress/Function_Reference/wp_count_posts
I think that will work here.
本文标签: count results in search page based on custom category
版权声明:本文标题:count results in search page based on custom category 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744629828a2616470.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
showposts
arguments is deprecated as of version 2.1, useposts_per_page
instead – Eugene Manuilov Commented Jun 6, 2012 at 7:10