Advertisement
BakerMan

WP Display Header - helper function for single events

Aug 26th, 2013
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. add_filter('wpdh_get_active_post_header', 'tribe_single_event_custom_headers');
  2.  
  3. function tribe_single_event_custom_headers($header) {
  4.     // Bow out if a header was found or if this is not a single event query
  5.     if (!empty($header) || !(is_singular() && tribe_is_event_query())) return $header;
  6.  
  7.     // Try to pull the actual single event post or bow out
  8.     global $wp_query;
  9.     if (count($wp_query->posts) !== 2 || !isset($wp_query->posts[0])) return $header;
  10.     $event = $wp_query->posts[0];
  11.  
  12.     // Determine if we've got a specific header image to show
  13.     $post_header = get_post_meta($event->ID, '_wpdh_display_header', true);
  14.     return $post_header;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement