Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: single_cat_title

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
528      $search = get_query_var('s');
529      $title = '';
530
531      $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
532
533      // If there's a category
534      if ( !empty($cat) ) {
535                // category exclusion
536                if ( !stristr($cat,'-') )
537                     $title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
538      } elseif ( !empty($category_name) ) {
539           if ( stristr($category_name,'/') ) {
540                     $category_name = explode('/',$category_name);
541                     if ( $category_name[count($category_name)-1] )
542                          $category_name = $category_name[count($category_name)-1]; // no trailing slash
543                     else
544                          $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
545           }
546           $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display');
547           if ( $cat )
548                $title = apply_filters('single_cat_title', $cat->name);
549      }
550
551      if ( !empty($tag) ) {
552           $tag = get_term($tag, 'post_tag', OBJECT, 'display');
553           if ( is_wp_error( $tag ) )
554                return $tag;
555           if ( ! empty($tag->name) )
556                $title = apply_filters('single_tag_title', $tag->name);
557      }
 
Line Code
688      global $wp_query;
689
690      if ( is_tag() )
691           return single_tag_title($prefix, $display);
692
693      if ( !is_category() )
694           return;
695
696      $cat = $wp_query->get_queried_object();
697      $my_cat_name = apply_filters('single_cat_title', $cat->name);
698      if ( !empty($my_cat_name) ) {
699           if ( $display )
700                echo $prefix . $my_cat_name;
701           else
702                return $my_cat_name;
703      }
704 }
705
706 /**