Amanda

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Showing total number of submitted or upcoming events #1468196
    Amanda
    Participant

    Thanks so much, Andras! Much appreciated! I’ll give that a shot.

    in reply to: Showing total number of submitted or upcoming events #1465913
    Amanda
    Participant

    Great! Thanks, Andras! First one works beautifully. Here’s the function I wrote for my theme’s functions.php file:

    function fr_tribe_events_count() {
    global $wpdb;
    $count_events = wp_count_posts( 'tribe_events' );
    $published_events = $count_events->publish;
    echo "
    <h2>Total approved events: "; print_r($published_events);
    echo "</h2>
    ";
    }
    add_action( 'tribe_events_after_the_title', 'fr_tribe_events_count' );

    And then I added the code

    <?php fr_tribe_events_count(); ?>

    to contents.php in wp-content\themes\mytheme\tribe-events\list. I now get a total at the top of my Events list for all events ever approved and published.

    But that second tutorial isn’t going to get me where I need to go to get a count of published Upcoming Events, though (which I’d rather have), because in WordPress “scheduled” posts just have a future date set in the post_date column in the table wp_posts, whereas The Events Calendar manages the list of Upcoming Events with a meta_key called _EventStartDate in the table wp_postmeta. That means I’m going to have to figure out some kind of join, which I’m not the best at. Any chance of a bit more help?

    I’d love this to be a feature in a future release, by the way! I think a lot of people would like to display the total number of Events or Upcoming Events.

    • This reply was modified 6 years, 2 months ago by Amanda. Reason: code display
    • This reply was modified 6 years, 2 months ago by Amanda. Reason: code display
    • This reply was modified 6 years, 2 months ago by Andras.
    • This reply was modified 6 years, 2 months ago by Andras.
Viewing 2 posts - 1 through 2 (of 2 total)