I have to show Post Number which is being view by the Visitor
e.g
Post 4 of 13 [Previous] [Next]
i have counted the total posts in the Category
$post_cat = get_the_category( $post->ID );
if($post_cat) {
$post_cat_id = $post_cat[0]->term_id;
$cat_posts = get_category($post_cat_id);
$total_posts = $cat_posts->category_count;
}
but problem is i don’t get the post number being view
You need to grab all posts ( with the same orderby parameter as used in your main query ) and locate the correct position.
Here is another version that I used if there are more than one category in a post. This code will try to use the parent category, if not found, it will use the first child category.
You can also use this with any taxonomy by just setting the taxonomy in the function like this
Here is the function