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
169      $year = get_query_var('year');
170      $monthnum = get_query_var('monthnum');
171      $day = get_query_var('day');
172      $title = '';
173
174      // If there's a category
175      if ( !empty($cat) ) {
176                // category exclusion
177                if ( !stristr($cat,'-') )
178                     $title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
179      } elseif ( !empty($category_name) ) {
180           if ( stristr($category_name,'/') ) {
181                     $category_name = explode('/',$category_name);
182                     if ( $category_name[count($category_name)-1] )
183                          $category_name = $category_name[count($category_name)-1]; // no trailing slash
184                     else
185                          $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
186           }
187           $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'");
188           $title = apply_filters('single_cat_title', $title);
189      }
190
191      // If there's an author
192      if ( !empty($author) ) {
193           $title = get_userdata($author);
194           $title = $title->display_name;
195      }
196      if ( !empty($author_name) ) {
197           // We do a direct query here because we don't cache by nicename.
 
Line Code
252           else
253                return strip_tags($title);
254      }
255 }
256
257
258 function single_cat_title($prefix = '', $display = true ) {
259      $cat = intval( get_query_var('cat') );
260      if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
261           $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
262           if ( !empty($my_cat_name) ) {
263                if ( $display )
264                     echo $prefix.strip_tags($my_cat_name);
265                else
266                     return strip_tags($my_cat_name);
267           }
268      }
269 }
270