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
156      $category_name = get_query_var('category_name');
157      $author = get_query_var('author');
158      $author_name = get_query_var('author_name');
159      $title = '';
160
161      // If there's a category
162      if ( !empty($cat) ) {
163                // category exclusion
164                if ( !stristr($cat,'-') )
165                     $title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
166      }
167      if ( !empty($category_name) ) {
168           if ( stristr($category_name,'/') ) {
169                     $category_name = explode('/',$category_name);
170                     if ( $category_name[count($category_name)-1] )
171                          $category_name = $category_name[count($category_name)-1]; // no trailing slash
172                     else
173                          $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
174           }
175           $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'");
176           $title = apply_filters('single_cat_title', $title);
177      }
178
179      // If there's an author
180      if ( !empty($author) ) {
181           $title = get_userdata($author);
182           $title = $title->display_name;
183      }
184      if ( !empty($author_name) ) {
185           // We do a direct query here because we don't cache by nicename.
 
Line Code
238           else
239                return strip_tags($title);
240      }
241 }
242
243
244 function single_cat_title($prefix = '', $display = true ) {
245      $cat = intval( get_query_var('cat') );
246      if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
247           $my_cat_name = apply_filters('single_cat_title', get_the_category_by_ID($cat));
248           if ( !empty($my_cat_name) ) {
249                if ( $display )
250                     echo $prefix.strip_tags($my_cat_name);
251                else
252                     return strip_tags($my_cat_name);
253           }
254      }
255 }
256