Hi there, I am using the following code to indicate the number of listings a vendor has published in the vendor footer. It shows the correct number everywhere on the website except on a single listings page! Could you kindly explain how to modify the code in order to show the correct count everywhere? Many thanks in advance!
add_filter(
'hivepress/v1/templates/vendor_view_block',
function( $template ) {
global $post;
$vendor_id = isset( $post->ID ) ? $post->ID : 0;
if ( $vendor_id ) {
$listing_count = HivePress\Models\Listing::query()
->filter([
'vendor' => $vendor_id,
])
->get_count();
$entry_text = $listing_count === 1 ? 'Eintrag' : 'Einträge';
$listing_count_html = '<div class="hp-vendor__listing-count">' . esc_html( $listing_count ) . ' ' . esc_html( $entry_text ) . '</div>';
$template = hivepress()->helper->merge_trees(
$template,
[
'blocks' => [
'vendor_footer' => [
'blocks' => [
'custom_vendor_listing_count' => [
'type' => 'content',
'content' => $listing_count_html,
'_order' => 5,
],
],
],
],
]
);
}
return $template;
},
1000
);