• Resolved CharlieAR

    (@charliear)


    Does anybody display a total count of Locations or of Events on at least one web page?
    I have put several functions in my child functions.php file but I depend on them being ready to go without me modifying them since I’m not a coder.

    I placed this in the functions.php file and placed a shortcode on my home page. It displayed “Locations listed” but no numeral of the total of Locations. It also doesn’t work if I substitute “posts” or any custom post type of mine instead of ‘locations’ so I guess my error is something fundamental; not because I’m trying to access EM data.

    function elementor_count_locations_shortcode( $atts ) {
    $count_locations = wp_count_posts('locations');
    $total_locations = $count_locations->publish;
    echo "Locations Listed " . $total_locations;
    }
    add_shortcode( 'my_elementor_total_locations', 'elementor_count_locations_shortcode');
Viewing 1 replies (of 1 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    You can try something like

    
    $events_count = EM_Events::count();
    $locations_count = EM_Locations::count();
    
Viewing 1 replies (of 1 total)
  • The topic ‘How to display a count of Locations or of Events’ is closed to new replies.