display post count custom post search results
-
Hello,
I’m trying to get a post results count to display on a custom post type search results page.I found this on another article:
table width="100%" cellspacing="0" cellpadding="0"> <tbody> <tr> <td align="left"> Results for <b><?php echo strip_tags($s); ?></b> </td> <td align="right">Results <?php $num_cb = $wp_query->post_count; $id_cb = $paged; $r_cb=1; $startNum_cb = $r_cb; $endNum_cb = 6; if($id_cb >=2) { $s_cb=$id_cb-1; $r_cb=($s_cb * 6) + 1; $startNum_cb=$r_cb; $endNum_cb=$startNum_cb + ($num_cb -1); } if (have_posts()) : echo "<b>$startNum_cb-$endNum_cb</b>"; endif; $totaltime= number_format($load,4); ?> of overall <?php $search_count = 0; $search = new WP_Query("s=$s & showposts=-1"); if($search->have_posts()) : while($search->have_posts()) : $search->the_post(); $search_count++; endwhile; endif; echo "<b>$search_count</b>. (<b>$totaltime</b> seconds)";?></td> </tr> </tbody> </table>
It works to show the number displayed on the page but won’t show the total. I can’t find how to change $wp_query->post_count; to refer to my custom post type.
Thanks
- The topic ‘display post count custom post search results’ is closed to new replies.