Thanks for writing back.
We're aware of a cache issue that sometimes causes the new messages to show up after some delay and it is being worked on.
If you don't want to use multiple post views as I suggested in my last reply, an alternate can be to use a custom shortcode that can give you the count of the location posts, with respective taxonomies.
Custom shortcode:
add_shortcode('get_post_count_by_tax', 'get_post_count_by_tax_func');
function get_post_count_by_tax_func($atts) {
$a = shortcode_atts( array(
'province' => '',
'type' => '',
'service' => '',
'post' => '',
), $atts );
// change these taxonomy slugs
$province_slug = 'add-province-tax-slug';
$type_slug = 'add-type-tax-slug';
$service_slug = 'add-service-tax-slug';
$tax_query = array('relation' => 'AND');
if(!empty($a['province'])) {
$tax_query[] = array(
'taxonomy' => $province_slug,
'field' => 'slug',
'terms' => $a['province'],
);
}
if(!empty($a['type'])) {
$tax_query[] = array(
'taxonomy' => $type_slug,
'field' => 'slug',
'terms' => $a['type'],
);
}
if(!empty($a['service'])) {
$tax_query[] = array(
'taxonomy' => $service_slug,
'field' => 'slug',
'terms' => $a['service'],
);
}
$args = array(
'post_type' => $a['post'],
'posts_per_page' => -1,
'post_status' => 'publish',
'fields' => 'ids',
'tax_query' => $tax_query
);
$posts_array = get_posts( $args );
return count($posts_array);
}
Please replace "add-province-tax-slug", "add-type-tax-slug", and "add-service-tax-slug" with the actual slugs of your website's province, type, and service taxonomies, respectively.
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
This custom shortcode accepts 4 parameters:
- post: slug of the post type to get the count from
- province: slug of the target term from the province taxonomy
- type: slug of the target term from the type taxonomy
- service: slug of the target term from the service taxonomy
Here are some usage examples:
To get the count of all posts in the "listing" post type with the province taxonomy term slug 'abc':
[get_post_count_by_tax post="listing" province="abc"]
To get the count of all posts in the "listing" post type with the province taxonomy term slug 'abc' and type taxonomy term slug 'def':
[get_post_count_by_tax post="listing" province="abc" type="def" ]
To get the count of all posts in the "listing" post type with the province taxonomy term slug 'abc' and service taxonomy term slug 'ghi':
[get_post_count_by_tax post="listing" province="abc" service="ghi" ]
To get the count of all posts in the "listing" post type with the province taxonomy term slug 'abc', type taxonomy term slug 'def', and service taxonomy term slug 'ghi':
[get_post_count_by_tax post="listing" province="abc" type="def" service="ghi"]
I hope this helps and please let me know if any point is not clear.
Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/