Support » Plugin: Event Organiser » Date not showing outside loop

  • Hi guys!

    I’m currently coding a custom template page for the single-event.php page.

    Everything is working fine, except getting the date to display.

    For the page itself, I am no longer using a loop, as I only need the information from this post.

    So, when I add the post thumbnail, I do it like this:

    <img src="<?php printf(
    	'%s',
    	get_the_post_thumbnail($event->ID)
    	); ?>
    ">

    This works fine.

    However, when I try to get the date to show, like this:

    <p class="beurs-detail-text">
      <?php
      printf(
        '%s',
        eo_the_start($format, $event->ID,null,$event->occurrence_id)
       );
       ?>
    </p>
    

    I get nothing. Am I doing something wrong? I can provide more code if needed :).

Viewing 1 replies (of 1 total)
  • psuba

    (@psuba)

    Something similar is happening in my case.
    I have a custom template to display search results and it crashes when I am trying to output search results that are event type. I get the following in the error log:

    PHP Fatal error:  Uncaught Exception: Error in formating DateTime object. Expected DateTime, but instead given boolean in /[siteroot]/public_html/wp-content/plugins/event-organiser/includes/event-organiser-utility-functions.php:31
    Stack trace:
    #0 /[siteroot]/public_html/wp-content/plugins/event-organiser/includes/event-organiser-utility-functions.php(164): eo_format_datetime(false, 'jS F Y g:i a')
    #1 /[themeroot]/eo-loop-single-event.php(32): eo_format_event_occurrence()

    Note that I am actually calling the same template display that works perfectly when displayed as part of the main loop (e.g. when I am displaying a list of events in the same category).

    However this crashes within the search results page when I am trying to display the event date, i.e. as I am calling

    echo eo_format_event_occurrence();

    I a guessing (not an expert) that the search query is constructed in a different way, and the eo core assumes that the query have extracted all the information needed for EO to pull together its metadata. However the search query may not have done this.
    It may have to do with how EO implements its hooks.

    In your case, the interesting question is whether you are getting the page object itself through a standard WP_Query (even if you are not iterating through the loop), or a different way (such as, in my case the Search query)?

Viewing 1 replies (of 1 total)
  • The topic ‘Date not showing outside loop’ is closed to new replies.