MyListing: Alle Listings zählen und dynamisch ausgeben

<?php  function countlistings_function( $atts ) { // Define here which listingtypes should be counted. Replace listingtypeX with your listing-slug // If you want count less listingstypes delete one or more lines. // If you want count more listingtypes add lines (type[3], type[4]) and so on.     $value = shortcode_atts(         array(             'type[0]' => 'listingtype1',             'type[1]' => 'listingtype2',             'type[2]' => 'listingtype3',             ),         $atts, 'total_listings');     $args = [             'post_type'      => 'job_listing',             'post_status'    => 'publish',                 'meta_query'     => [ [                 'key'            => '_case27_listing_type',                 'value'          =>  $value,                 ] ],         ];                 $query = new WP_Query( $args );     $total = $query->found_posts;     return $total; } add_shortcode( 'total_listings', 'countlistings_function' );
listingtype1, listingtype2 usw. muss mit dem Slug des zu zählenden Listingtypes ersetzt werden. Der Array kann auch noch weiter ergänzt werden. Der Shortcode lautet dann [total-listings]. Dieser kann dann auch wunderbar als dynamischer Wert in Elementor Widgets benutzt werden.
Füge den Code einfach in die functions.php deines Child-Themes oder nutze ein Code Snippet Pugin, wie zum Beispiel AdvancedScripts oder noch besser WPCodeBox.