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
81 function get_the_category_by_ID($cat_ID) {
82      $cat_ID = (int) $cat_ID;
83      $category = &get_category($cat_ID);
84      return $category->cat_name;
85 }
86
87 function get_the_category_list($separator = '', $parents='') {
88      $categories = get_the_category();
89      if (empty($categories))
90           return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
91
92      $thelist = '';
93      if ( '' == $separator ) {
94           $thelist .= '<ul class="post-categories">';
95           foreach ( $categories as $category ) {
96                $thelist .= "\n\t<li>";
97                switch ( strtolower($parents) ) {
98                     case 'multiple':
99                          if ($category->category_parent)
 
Line Code
130                          $thelist .= "$category->cat_name</a>";
131                          break;
132                     case '':
133                     default:
134                          $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
135                }
136                ++$i;
137           }
138      }
139      return apply_filters('the_category', $thelist, $separator, $parents);
140 }
141
142 function in_category($category) { // Check if the current post is in the given category
143      global $category_cache, $post, $blog_id;
144
145      if ( isset( $category_cache[$blog_id][$post->ID][$category] ) )
146           return true;
147      else
148           return false;