I have a review section on the WP website.
I'd like to count posts with the same titles inside the 'review' category and display the counter.
I managed to do it with the tag field:
<?php
global $post;
$postslist = get_posts( array( 'post_type' => 'reviews', 'posts_per_page' => 20, 'order'=> 'ASC', 'orderby' => 'date' ) );
foreach ( $postslist as $post ){
setup_postdata($post);
?>
<?php
// Tag counter
$post_tags = get_the_tags($post->ID);
if ($post_tags) {
foreach($post_tags as $tag){
echo '<span class="review-count">' . $tag->count . ' review(s)' . '</span>';
}
}
?>
But thought it would be more convenient to use title field instead