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
205  * @param string $separator Optional, default is empty string. Separator for between the categories.
206  * @param string $parents Optional. How to display the parents.
207  * @param int $post_id Optional. Post ID to retrieve categories.
208  * @return string
209  */
210 function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
211      global $wp_rewrite;
212      $categories = get_the_category( $post_id );
213      if ( empty( $categories ) )
214           return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
215
216      $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
217
218      $thelist = '';
219      if ( '' == $separator ) {
220           $thelist .= '<ul class="post-categories">';
221           foreach ( $categories as $category ) {
222                $thelist .= "\n\t<li>";
223                switch ( strtolower( $parents ) ) {
 
Line Code
256                          $thelist .= "$category->cat_name</a>";
257                          break;
258                     case '':
259                     default:
260                          $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . $rel . '>' . $category->name.'</a>';
261                }
262                ++$i;
263           }
264      }
265      return apply_filters( 'the_category', $thelist, $separator, $parents );
266 }
267
268
269 /**
270  * Check if the current post in within any of the given categories.
271  *
272  * The given categories are checked against the post's categories' term_ids, names and slugs.
273  * Categories given as integers will only be checked against the post's categories' term_ids.
274  *