I'm building a villa rental website, I have two custom post types named "Villa" (used to show villas) and "Destination".
I have installed the CPT-onomies plugin and I use the "Destination" as custom taxonomy for the villas
post type.
I want on each Destination post (ex. the post showing Greece as destination) to show the number of Villas (posts) assigned to that Destination (custom post type).
I have read thisthis post but this code is only showing a list of all taxonomies and next to it a number showing the post count.
This is the code showing all the taxonomies and post count.
$terms = get_terms('countries');
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
$term = sanitize_term( $term, 'countries' );
$term_link = get_term_link( $term, 'countries' );
echo '<li><a href="' . esc_url( $term_link ) . '">' . $term->name . ' (' . $term->count . ')' . '</a></li>';
}
echo '</ul>';
}
Thank you for your help. Sorry but English is not my native language I tried to describe my problem best possible.