Guest User

get_organizer_by_slug (TEC/ECP 2.0.10)

a guest
Dec 14th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. /**
  2.  * Returns the post object for an organizer who should be identified
  3.  * by slug.
  4.  *
  5.  * If the organizer cannot be found (bool) false will be returned.
  6.  *
  7.  * @param $slug
  8.  * @return bool|object
  9.  */
  10. function get_organizer_by_slug($slug) {
  11.     $query = new WP_Query("name=$slug&post_type=".TribeEvents::ORGANIZER_POST_TYPE);
  12.  
  13.     // Successful query? Return the first object if so (we anyway expect the slug to be unique)
  14.     if ($query->have_posts()) {
  15.         $query->the_post();
  16.         $post = $query->post;
  17.         wp_reset_query();
  18.         return $post;
  19.     }
  20.  
  21.     else return false;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment