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
110      if ( is_wp_error( $category ) )
111           return $category;
112      return $category->name;
113 }
114
115 function get_the_category_list($separator = '', $parents='', $post_id = false) {
116      global $wp_rewrite;
117      $categories = get_the_category($post_id);
118      if (empty($categories))
119           return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
120
121      $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
122
123      $thelist = '';
124      if ( '' == $separator ) {
125           $thelist .= '<ul class="post-categories">';
126           foreach ( $categories as $category ) {
127                $thelist .= "\n\t<li>";
128                switch ( strtolower($parents) ) {
 
Line Code
161                          $thelist .= "$category->cat_name</a>";
162                          break;
163                     case '':
164                     default:
165                          $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->name.'</a>';
166                }
167                ++$i;
168           }
169      }
170      return apply_filters('the_category', $thelist, $separator, $parents);
171 }
172
173 /*
174  * in_category() - Checks whether the current post is within a particular category
175  *
176  * This function checks to see if the post is within the supplied category.  The categoy
177  * can be specified by number or name and will be checked as a name first to allow for categories with numeric names.
178  * Note: Prior to v2.5 of WordPress category names where not supported.
179  *