WP_Query count posts – custom Post Type

The wp_count_posts function has parameter $type for post type to count, you should use this parameter if you want to count the number of schusslersalz

A snippet

$count_posts = wp_count_posts( 'schusslersalz' )->publish;
echo $count_posts;

Full snippet as follow:

$args = array(
  'post_type' => 'schusslersalz'
);
$the_query = new WP_Query( $args );
echo $the_query->found_posts;

I hope this code helped

Leave a Comment