mercredi 25 mars 2015

Post count for category and tag


I have this code that counts the result found when a search is made. Here goes the code.



<?php /* Search Count */
$allsearch = &new WP_Query("s=$s&showposts=-1");
$key = wp_specialchars($s, 1);
$count = $allsearch->post_count;
$text = '<span class="resultsFound">';
if ( $allsearch->found_posts <= 0 ) {
$text .= sprintf(__( '( Nothing Found )' ), $count );
}

elseif ( $allsearch->found_posts <= 1 ) {
$text .= sprintf(__( '( We found %d company )' ), $count );
}

else {
$text .= sprintf(__( '( We found %d companies )' ), $count );
}
$text .= '</span>';
echo $text;
?>


The code above is the code for counting all the post found in search page. I want to apply this function to my category as well as tag page. Any solution?





Aucun commentaire:

Enregistrer un commentaire