WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 3 times in this file.
Line | Code |
---|---|
123 | * in an unordered list. An empty string will result in the default behavior. |
124 | * @param string $parents Optional. How to display the parents. |
125 | * @param int $post_id Optional. Post ID to retrieve categories. |
126 | * @return string |
127 | */ |
128 | function get_the_category_list( $separator = '', $parents = '', $post_id = false ) { |
129 | global $wp_rewrite; |
130 | if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) { |
131 | /** This filter is documented in wp-includes/category-template.php */ |
132 | return apply_filters( 'the_category', '', $separator, $parents ); |
133 | } |
134 |
|
135 | /** |
136 | * Filters the categories before building the category list. |
137 | * |
138 | * @since 4.4.0 |
139 | * |
140 | * @param array $categories An array of the post's categories. |
141 | * @param int|bool $post_id ID of the post we're retrieving categories for. When `false`, we assume the |
142 | * current post in the loop. |
143 | */ |
144 | $categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id ); |
145 |
|
146 | if ( empty( $categories ) ) { |
147 | /** This filter is documented in wp-includes/category-template.php */ |
148 | return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents ); |
149 | } |
150 |
|
151 | $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"'; |
152 |
|
153 | $thelist = ''; |
154 | if ( '' == $separator ) { |
155 | $thelist .= '<ul class="post-categories">'; |
156 | foreach ( $categories as $category ) { |
157 | $thelist .= "\n\t<li>"; |
Line | Code |
202 | * Filters the category or list of categories. |
203 | * |
204 | * @since 1.2.0 |
205 | * |
206 | * @param string $thelist List of categories for the current post. |
207 | * @param string $separator Separator used between the categories. |
208 | * @param string $parents How to display the category parents. Accepts 'multiple', |
209 | * 'single', or empty. |
210 | */ |
211 | return apply_filters( 'the_category', $thelist, $separator, $parents ); |
212 | } |
213 |
|
214 | /** |
215 | * Check if the current post is within any of the given categories. |
216 | * |
217 | * The given categories are checked against the post's categories' term_ids, names and slugs. |
218 | * Categories given as integers will only be checked against the post's categories' term_ids. |
219 | * |
220 | * Prior to v2.5 of WordPress, category names were not supported. |