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
107      if ( is_wp_error( $category ) )
108           return $category;
109      return $category->name;
110 }
111
112 function get_the_category_list($separator = '', $parents='') {
113      global $wp_rewrite;
114      $categories = get_the_category();
115      if (empty($categories))
116           return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
117
118      $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
119
120      $thelist = '';
121      if ( '' == $separator ) {
122           $thelist .= '<ul class="post-categories">';
123           foreach ( $categories as $category ) {
124                $thelist .= "\n\t<li>";
125                switch ( strtolower($parents) ) {
 
Line Code
158                          $thelist .= "$category->cat_name</a>";
159                          break;
160                     case '':
161                     default:
162                          $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->name.'</a>';
163                }
164                ++$i;
165           }
166      }
167      return apply_filters('the_category', $thelist, $separator, $parents);
168 }
169
170 function in_category( $category ) { // Check if the current post is in the given category
171      global $post, $blog_id;
172
173      $categories = get_object_term_cache($post->ID, 'category');
174      if ( false === $categories )
175           $categories = wp_get_object_terms($post->ID, 'category');
176      if(array_key_exists($category, $categories))