I just want to show the total number of custom posts matching some conditions (arguments).
Do I have to make the entire query (get_posts, query_posts...) and get found_posts from it or is there a more efficient way to query the totals?
For instance (using an events plugin),
$args = array( 'posts_per_page' => -1, 'post_type' => 'event', 'suppress_filters' => false, 'showpastevents' => true, 'post_status' => 'published', 'group_events_by' => 'series', 'meta_query' => array( array( 'key' => '_event_public', 'value' => '1', ) ) ); $q_posts = get_posts($args); $alltime_events = count($q_posts);
is giving me 1344 events. Is that not an inefficient query?
'fields' => 'ids' to the query arguments to only retrieve the ids instead of the whole post object, but I am just guessing it might save some work.