[ Index ] |
PHP Cross Reference of WordPress |
[Source view] [Print] [Project Stats]
Taxonomy API: Core category-specific template tags
File Size: | 1543 lines (56 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
get_category_link( $category ) X-Ref |
Retrieves category link URL. return: string Link on success, empty string if category does not exist. param: int|object $category Category ID or object. since: 1.0.0 |
get_category_parents( $category_id, $link = false, $separator = '/', $nicename = false, $deprecated = array() X-Ref |
Retrieves category parents with separator. return: string|WP_Error A list of category parents on success, WP_Error on failure. param: int $category_id Category ID. param: bool $link Optional. Whether to format with link. Default false. param: string $separator Optional. How to separate categories. Default '/'. param: bool $nicename Optional. Whether to use nice name for display. Default false. param: array $deprecated Not used. since: 1.2.0 since: 4.8.0 The `$visited` parameter was deprecated and renamed to `$deprecated`. |
get_the_category( $post_id = false ) X-Ref |
Retrieves post categories. This tag may be used outside The Loop by passing a post ID as the parameter. Note: This function only returns results from the default "category" taxonomy. For custom taxonomies use get_the_terms(). return: WP_Term[] Array of WP_Term objects, one for each category assigned to the post. param: int $post_id Optional. The post ID. Defaults to current post ID. since: 0.71 |
get_the_category_by_ID( $cat_id ) X-Ref |
Retrieves category name based on category ID. return: string|WP_Error Category name on success, WP_Error on failure. param: int $cat_id Category ID. since: 0.71 |
get_the_category_list( $separator = '', $parents = '', $post_id = false ) X-Ref |
Retrieves category list for a post in either HTML list or custom format. Generally used for quick, delimited (e.g. comma-separated) lists of categories, as part of a post entry meta. For a more powerful, list-based function, see wp_list_categories(). return: string Category list for a post. param: string $separator Optional. Separator between the categories. By default, the links are placed param: string $parents Optional. How to display the parents. param: int $post_id Optional. Post ID to retrieve categories. since: 1.5.1 |
in_category( $category, $post = null ) X-Ref |
Checks if the current post is within any of the given categories. The given categories are checked against the post's categories' term_ids, names and slugs. Categories given as integers will only be checked against the post's categories' term_ids. Prior to v2.5 of WordPress, category names were not supported. Prior to v2.7, category slugs were not supported. Prior to v2.7, only one category could be compared: in_category( $single_category ). Prior to v2.7, this function could only be used in the WordPress Loop. As of 2.7, the function can be used anywhere if it is provided a post ID or post object. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool True if the current post is in any of the given categories. param: int|string|int[]|string[] $category Category ID, name, slug, or array of such param: int|object $post Optional. Post to check instead of the current post. since: 1.2.0 since: 2.7.0 The `$post` parameter was added. |
the_category( $separator = '', $parents = '', $post_id = false ) X-Ref |
Displays category list for a post in either HTML list or custom format. param: string $separator Optional. Separator between the categories. By default, the links are placed param: string $parents Optional. How to display the parents. param: int $post_id Optional. Post ID to retrieve categories. since: 0.71 |
category_description( $category = 0 ) X-Ref |
Retrieves category description. return: string Category description, if available. param: int $category Optional. Category ID. Defaults to the current category ID. since: 1.0.0 |
wp_dropdown_categories( $args = '' ) X-Ref |
Displays or retrieves the HTML dropdown list of categories. The 'hierarchical' argument, which is disabled by default, will override the depth argument, unless it is true. When the argument is false, it will display all of the categories. When it is enabled it will use the value in the 'depth' argument. return: string HTML dropdown list of categories. param: array|string $args { since: 2.1.0 since: 4.2.0 Introduced the `value_field` argument. since: 4.6.0 Introduced the `required` argument. |
wp_list_categories( $args = '' ) X-Ref |
Displays or retrieves the HTML list of categories. return: void|string|false Void if 'echo' argument is true, HTML list of categories if 'echo' is false. param: array|string $args { since: 2.1.0 since: 4.4.0 Introduced the `hide_title_if_empty` and `separator` arguments. since: 4.4.0 The `current_category` argument was modified to optionally accept an array of values. |
wp_tag_cloud( $args = '' ) X-Ref |
Displays a tag cloud. Outputs a list of tags in what is called a 'tag cloud', where the size of each tag is determined by how many times that particular tag has been assigned to posts. return: void|string|string[] Void if 'echo' argument is true, or on failure. Otherwise, tag cloud param: array|string $args { since: 2.3.0 since: 2.8.0 Added the `taxonomy` argument. since: 4.8.0 Added the `show_count` argument. |
default_topic_count_scale( $count ) X-Ref |
Default topic count scaling for tag links. return: int Scaled count. param: int $count Number of posts with that tag. since: 2.9.0 |
wp_generate_tag_cloud( $tags, $args = '' ) X-Ref |
Generates a tag cloud (heatmap) from provided data. return: string|string[] Tag cloud as a string or an array, depending on 'format' argument. param: WP_Term[] $tags Array of WP_Term objects to generate the tag cloud for. param: string|array $args { since: 2.3.0 since: 4.8.0 Added the `show_count` argument. |
_wp_object_name_sort_cb( $a, $b ) X-Ref |
Serves as a callback for comparing objects based on name. Used with `uasort()`. return: int Negative number if `$a->name` is less than `$b->name`, zero if they are equal, param: object $a The first object to compare. param: object $b The second object to compare. since: 3.1.0 |
_wp_object_count_sort_cb( $a, $b ) X-Ref |
Serves as a callback for comparing objects based on count. Used with `uasort()`. return: bool Whether the count value for `$a` is greater than the count value for `$b`. param: object $a The first object to compare. param: object $b The second object to compare. since: 3.1.0 |
walk_category_tree( ...$args ) X-Ref |
Retrieves HTML list content for category list. return: string param: mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments. since: 2.1.0 since: 5.3.0 Formalized the existing `...$args` parameter by adding it |
walk_category_dropdown_tree( ...$args ) X-Ref |
Retrieves HTML dropdown (select) content for category list. return: string param: mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments. since: 2.1.0 since: 5.3.0 Formalized the existing `...$args` parameter by adding it |
get_tag_link( $tag ) X-Ref |
Retrieves the link to the tag. return: string Link on success, empty string if tag does not exist. param: int|object $tag Tag ID or object. since: 2.3.0 |
get_the_tags( $post_id = 0 ) X-Ref |
Retrieves the tags for a post. return: WP_Term[]|false|WP_Error Array of WP_Term objects on success, false if there are no terms param: int|WP_Post $post_id Post ID or object. since: 2.3.0 |
get_the_tag_list( $before = '', $sep = '', $after = '', $post_id = 0 ) X-Ref |
Retrieves the tags for a post formatted as a string. return: string|false|WP_Error A list of tags on success, false if there are no terms, param: string $before Optional. String to use before the tags. Default empty. param: string $sep Optional. String to use between the tags. Default empty. param: string $after Optional. String to use after the tags. Default empty. param: int $post_id Optional. Post ID. Defaults to the current post ID. since: 2.3.0 |
the_tags( $before = null, $sep = ', ', $after = '' ) X-Ref |
Displays the tags for a post. param: string $before Optional. String to use before the tags. Defaults to 'Tags:'. param: string $sep Optional. String to use between the tags. Default ', '. param: string $after Optional. String to use after the tags. Default empty. since: 2.3.0 |
tag_description( $tag = 0 ) X-Ref |
Retrieves tag description. return: string Tag description, if available. param: int $tag Optional. Tag ID. Defaults to the current tag ID. since: 2.8.0 |
term_description( $term = 0, $deprecated = null ) X-Ref |
Retrieves term description. return: string Term description, if available. param: int $term Optional. Term ID. Defaults to the current term ID. param: null $deprecated Deprecated. Not used. since: 2.8.0 since: 4.9.2 The `$taxonomy` parameter was deprecated. |
get_the_terms( $post, $taxonomy ) X-Ref |
Retrieves the terms of the taxonomy that are attached to the post. return: WP_Term[]|false|WP_Error Array of WP_Term objects on success, false if there are no terms param: int|WP_Post $post Post ID or object. param: string $taxonomy Taxonomy name. since: 2.5.0 |
get_the_term_list( $post_id, $taxonomy, $before = '', $sep = '', $after = '' ) X-Ref |
Retrieves a post's terms as a list with specified format. Terms are linked to their respective term listing pages. return: string|false|WP_Error A list of terms on success, false if there are no terms, param: int $post_id Post ID. param: string $taxonomy Taxonomy name. param: string $before Optional. String to use before the terms. Default empty. param: string $sep Optional. String to use between the terms. Default empty. param: string $after Optional. String to use after the terms. Default empty. since: 2.5.0 |
get_term_parents_list( $term_id, $taxonomy, $args = array() X-Ref |
Retrieves term parents with separator. return: string|WP_Error A list of term parents on success, WP_Error or empty string on failure. param: int $term_id Term ID. param: string $taxonomy Taxonomy name. param: string|array $args { since: 4.8.0 |
the_terms( $post_id, $taxonomy, $before = '', $sep = ', ', $after = '' ) X-Ref |
Displays the terms for a post in a list. return: void|false Void on success, false on failure. param: int $post_id Post ID. param: string $taxonomy Taxonomy name. param: string $before Optional. String to use before the terms. Default empty. param: string $sep Optional. String to use between the terms. Default ', '. param: string $after Optional. String to use after the terms. Default empty. since: 2.5.0 |
has_category( $category = '', $post = null ) X-Ref |
Checks if the current post has any of given category. The given categories are checked against the post's categories' term_ids, names and slugs. Categories given as integers will only be checked against the post's categories' term_ids. If no categories are given, determines if post has any categories. return: bool True if the current post has any of the given categories param: string|int|array $category Optional. The category name/term_id/slug, param: int|object $post Optional. Post to check instead of the current post. since: 3.1.0 |
has_tag( $tag = '', $post = null ) X-Ref |
Checks if the current post has any of given tags. The given tags are checked against the post's tags' term_ids, names and slugs. Tags given as integers will only be checked against the post's tags' term_ids. If no tags are given, determines if post has any tags. For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook. return: bool True if the current post has any of the given tags param: string|int|array $tag Optional. The tag name/term_id/slug, param: int|object $post Optional. Post to check instead of the current post. since: 2.6.0 since: 2.7.0 Tags given as integers are only checked against since: 2.7.0 Can be used outside of the WordPress Loop if `$post` is provided. |
has_term( $term = '', $taxonomy = '', $post = null ) X-Ref |
Checks if the current post has any of given terms. The given terms are checked against the post's terms' term_ids, names and slugs. Terms given as integers will only be checked against the post's terms' term_ids. If no terms are given, determines if post has any terms. return: bool True if the current post has any of the given terms param: string|int|array $term Optional. The term name/term_id/slug, param: string $taxonomy Optional. Taxonomy name. Default empty. param: int|WP_Post $post Optional. Post to check instead of the current post. since: 3.1.0 |
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |