Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: the_category

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 2 times in this file.

Line Code
87      $cat_ID = (int) $cat_ID;
88      $category = &get_category($cat_ID);
89      return $category->cat_name;
90 }
91
92 function get_the_category_list($separator = '', $parents='') {
93      global $wp_rewrite;
94      $categories = get_the_category();
95      if (empty($categories))
96           return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
97
98      $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
99
100      $thelist = '';
101      if ( '' == $separator ) {
102           $thelist .= '<ul class="post-categories">';
103           foreach ( $categories as $category ) {
104                $thelist .= "\n\t<li>";
105                switch ( strtolower($parents) ) {
 
Line Code
138                          $thelist .= "$category->cat_name</a>";
139                          break;
140                     case '':
141                     default:
142                          $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a>';
143                }
144                ++$i;
145           }
146      }
147      return apply_filters('the_category', $thelist, $separator, $parents);
148 }
149
150 function in_category($category) { // Check if the current post is in the given category
151      global $category_cache, $post, $blog_id;
152
153      if ( isset( $category_cache[$blog_id][$post->ID][$category] ) )
154           return true;
155      else
156           return false;