Display start date in WP basic search result

WordPress Event Management, Calendars & Registration Forums General Question Display start date in WP basic search result

This topic contains 2 replies, has 2 voices, and was last updated by  Vincent 1 week, 5 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #40035

    Hello,

    Our events are listed in the basic WP search result.
    We would like to add the start date after the title if it’s an event.

    In content-search.php: we used this:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    <header class="entry-header">
        <?php the_title( sprintf( '<h2 class="entry-title">', esc_url( get_permalink() ) ), '</h2>' ); ?>
    </header><!-- .entry-header -->
    
    <?php $date= eo_get_the_start( 'Ymd', $post_id ); echo $date; ?>
    
    <div class="entry-summary">
        <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    </article><!-- #post-<?php the_ID(); ?> -->
    

    without no success…

    If we try with the venues… we add:

    <?php echo 'Place:'.eo_get_venue_name(); ?>
    

    We get the Venue name in our search result.
    Everything ok

    BUT i don’t get the start date with all this test:

    <?php echo 'Date: '.eo_get_the_start(); ?>
    <?php echo 'Date: '.eo_get_the_start( 'jS F Y', $post->ID ); ?>
    <?php echo eo_get_the_start('jS M YY', $post->ID); ?>
    <?php echo eo_get_the_start("jS M YY"); ?>
    <?php echo eo_get_the_start(); ?>
    <?php echo eo_get_the_start( 'jS F Y', $post->ID, $post->occurrence_id ); ?>
    <?php eo_the_start( $format = 'd-m-Y', $post->ID );?>
    <?php eo_the_start( $post->ID );?>
    

    Somebody could help me?

    Thank’s

    V.

    Vincent
    #40040

    Hi Vincent,

    Events returned by the WordPress search are effectively ordinary posts, and do not have any dates associated with them. This is because the an “event” (regardless of how many dates it has), is a custom post type, and when searching across post types the search query does not join the event dates.

    If you only have single-occurrence events, or are happy to only display the first or next dates of the event returned, it’s possible to fetch that information. But it”s not possible to duplicate the event in the search results, one for each date.

    For the next occurrence of an event: http://codex.wp-event-organiser.com/function-eo_get_next_occurrence_of.html

    For the first occurrence of an event: http://codex.wp-event-organiser.com/function-eo_get_schedule_start.html

    In other words, you can use any function that requires only the event (post) ID. If you need to call a function for which you need the occurrence ID you need to decide how you will determine that (e.g. using the only occurrence ID of a single-occurrence event).

    Stephen Harris
    #40044

    Hello Stephen,
    Thank’s for this very complete answer…
    I get the date in the search results now!
    … and for this great plugin.
    Best
    V.

    Vincent
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.