Automattic / eventbrite-api

The Eventbrite API plugin brings the power of Eventbrite to WordPress, for both users and developers.
68 stars 40 forks source link

filter_event_permalink filters any call to get_permalink while event is the global post #49

Open brybeecher opened 8 years ago

brybeecher commented 8 years ago

filter_event_permalink will filter all calls to get_permalink while the global $post is the event.

Eg. I was iterating over a list of plain, non-event post objects within the eventbrite-single.php intending to output their permalinks, but calls such as get_permalink($my_post) will always return the permalink for the current event.

I tried to add $post as an arg to filter_event_permalink so it would only conditionally change the permalink but the arg never seemed to be populated.

My work around was to just call setup_postdata($my_post) and wp_reset_postdata() for every post object. Hope it saves someone some time.

brybeecher commented 7 years ago

Related: (as I came across more troubles related to the filter_event_permalink function). Getting the event permalinks from a page that is not an eventbrite-index template gives an incorrect URL. This seems to be due to filter_event_permalink using the get_queried_object() function, it assumes we are on an eventbrite-index template. My workaround was writing my own function based on the existing filter_event-Permalink

$pages = get_pages(array(
  'meta_key' => '_wp_page_template',
  'meta_value' => 'eventbrite-index.php',
));
$eb_index_page = $pages[0]; // any EB index page should be fine

Replacing get_queried_object() with $eb_index_page