Advertisement
BakerMan

Display category name out-of-loop (The Events Calendar)

Aug 20th, 2012
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. // We only want to run this for single instances
  2. if (is_single()) {
  3.     // Load the categories associated with this event
  4.     $terms = get_the_terms(get_the_ID(), TribeEvents::TAXONOMY);
  5.    
  6.     // If any were returned, display the name of the *first* category
  7.     if (count($terms) > 0) {
  8.         $category = array_shift($terms);
  9.         echo $category->name;
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement