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
424      $search = get_query_var('s');
425      $title = '';
426
427      $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
428
429      // If there's a category
430      if ( !empty($cat) ) {
431                // category exclusion
432                if ( !stristr($cat,'-') )
433                     $title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
434      } elseif ( !empty($category_name) ) {
435           if ( stristr($category_name,'/') ) {
436                     $category_name = explode('/',$category_name);
437                     if ( $category_name[count($category_name)-1] )
438                          $category_name = $category_name[count($category_name)-1]; // no trailing slash
439                     else
440                          $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
441           }
442           $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display');
443           if ( $cat )
444                $title = apply_filters('single_cat_title', $cat->name);
445      }
446
447      if ( !empty($tag) ) {
448           $tag = get_term($tag, 'post_tag', OBJECT, 'display');
449           if ( is_wp_error( $tag ) )
450                return $tag;
451           if ( ! empty($tag->name) )
452                $title = apply_filters('single_tag_title', $tag->name);
453      }
 
Line Code
578  * @since 0.71
579  *
580  * @param string $prefix Optional. What to display before the title.
581  * @param bool $display Optional, default is true. Whether to display or retrieve title.
582  * @return string|null Title when retrieving, null when displaying or failure.
583  */
584 function single_cat_title($prefix = '', $display = true ) {
585      $cat = intval( get_query_var('cat') );
586      if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
587           $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
588           if ( !empty($my_cat_name) ) {
589                if ( $display )
590                     echo $prefix.strip_tags($my_cat_name);
591                else
592                     return strip_tags($my_cat_name);
593           }
594      } else if ( is_tag() ) {
595           return single_tag_title($prefix, $display);
596      }