Support » Plugin: Events Manager » Event date/time being filtered too aggressively

  • Resolved Boone Gorges


    Scenario: I’ve got a single event page (say E1), and on that page, I’m showing a list of other events, outside of a WordPress loop (E2, E3, E4), and showing their dates using get_the_date(). events-manager has filters EM_Event_Post::the_date() and EM_Event_Post::the_time() that filter event dates to make sure they match the start date of the event. In this scenario, these filters are too aggressive. Briefly:

    	public static function the_date( $the_date, $d = '' ){
    		global $post;
    		if( $post->post_type == EM_POST_TYPE_EVENT ){

    Because the current page is an event, $GLOBALS['post']->post_type == EM_POST_TYPE_EVENT is true. But the filter then sets the start date of E2 and E3 and E4 to E1->start, since this is the value from $post.

    The get_the_date and get_the_time filters pass the proper $post object. So the fix should be pretty easy. Change the add_filter() calls so that they expect 3 rather than 2 parameters, and then change the first few lines to:

    	public static function the_date( $the_date, $d = '', $post = null ){
                    $post = get_post( $post );
    		if( $post->post_type == EM_POST_TYPE_EVENT ){
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marcus


    Hi Boone,

    I’ve seen others do that with the_content causing post content to never change in our lists outside the loop, we’re doing the same here….

    Therefore, I see what you mean, agree and will fix for next update. Thanks for pointing that out! Will update here when the fix is out.

    Plugin Author Marcus


    @boonebgorges Sorry I never updated you about this, but the issue got fixed in 5.7, a few updates back.

    Thanks for pointing this out, I noticed it was doing it for get_the_ and just the_ filters, whereas only get_the_ filters were needed, so two bugs one thread!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.