[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> category-template.php (summary)

Taxonomy API: Core category-specific template tags

File Size: 1467 lines (52 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 30 functions

  get_category_link()
  get_category_parents()
  get_the_category()
  get_the_category_by_ID()
  get_the_category_list()
  in_category()
  the_category()
  category_description()
  wp_dropdown_categories()
  wp_list_categories()
  wp_tag_cloud()
  default_topic_count_scale()
  wp_generate_tag_cloud()
  _wp_object_name_sort_cb()
  _wp_object_count_sort_cb()
  walk_category_tree()
  walk_category_dropdown_tree()
  get_tag_link()
  get_the_tags()
  get_the_tag_list()
  the_tags()
  tag_description()
  term_description()
  get_the_terms()
  get_the_term_list()
  get_term_parents_list()
  the_terms()
  has_category()
  has_tag()
  has_term()

Functions
Functions that are not part of a class:

get_category_link( $category )   X-Ref
Retrieve category link URL.

return: string Link on success, empty string if category does not exist.
param: int|object $category Category ID or object.

get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $deprecated = array()   X-Ref
Retrieve category parents with separator.

return: string|WP_Error A list of category parents on success, WP_Error on failure.
param: int $id Category ID.
param: bool $link Optional, default is false. Whether to format with link.
param: string $separator Optional, default is '/'. How to separate categories.
param: bool $nicename Optional, default is false. Whether to use nice name for display.
param: array $deprecated Not used.

get_the_category( $id = false )   X-Ref
Retrieve 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 $id Optional, default to current post ID. The post ID.

get_the_category_by_ID( $cat_ID )   X-Ref
Retrieve category name based on category ID.

return: string|WP_Error Category name on success, WP_Error on failure.
param: int $cat_ID Category ID.

get_the_category_list( $separator = '', $parents = '', $post_id = false )   X-Ref
Retrieve category list for a post in either HTML list or custom format.

return: string
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.

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|array $category Category ID, name or slug, or array of said.
param: int|object $post Optional. Post to check instead of the current post. (since 2.7.0)

the_category( $separator = '', $parents = '', $post_id = false )   X-Ref
Display 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.

category_description( $category = 0 )   X-Ref
Retrieve category description.

return: string Category description, available.
param: int $category Optional. Category ID. Will use global category ID by default.

wp_dropdown_categories( $args = '' )   X-Ref
Display or retrieve 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 content only if 'echo' argument is 0.
param: string|array $args {

wp_list_categories( $args = '' )   X-Ref
Display or retrieve the HTML list of categories.

return: false|string HTML content only if 'echo' argument is 0.
param: string|array $args {

wp_tag_cloud( $args = '' )   X-Ref
Displays a tag cloud.

return: void|array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
param: array|string $args {

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.

wp_generate_tag_cloud( $tags, $args = '' )   X-Ref
Generates a tag cloud (heatmap) from provided data.

return: string|array 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 {

_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.

_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.

walk_category_tree()   X-Ref
Retrieve HTML list content for category list.

return: string

walk_category_dropdown_tree()   X-Ref
Retrieve HTML dropdown (select) content for category list.

return: string

get_tag_link( $tag )   X-Ref
Retrieve 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.

get_the_tags( $id = 0 )   X-Ref
Retrieve the tags for a post.

return: array|false|WP_Error Array of tag objects on success, false on failure.
param: int $id Post ID.

get_the_tag_list( $before = '', $sep = '', $after = '', $id = 0 )   X-Ref
Retrieve 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, WP_Error on failure.
param: string $before Optional. Before tags.
param: string $sep Optional. Between tags.
param: string $after Optional. After tags.
param: int $id Optional. Post ID. Defaults to the current post.

the_tags( $before = null, $sep = ', ', $after = '' )   X-Ref
Retrieve the tags for a post.

param: string $before Optional. Before list.
param: string $sep Optional. Separate items using this.
param: string $after Optional. After list.

tag_description( $tag = 0 )   X-Ref
Retrieve tag description.

return: string Tag description, available.
param: int $tag Optional. Tag ID. Will use global tag ID by default.

term_description( $term = 0, $deprecated = null )   X-Ref
Retrieve term description.

return: string Term description, available.
param: int  $term       Optional. Term ID. Will use global term ID by default.
param: null $deprecated Deprecated argument.

get_the_terms( $post, $taxonomy )   X-Ref
Retrieve 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.

get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' )   X-Ref
Retrieve a post's terms as a list with specified format.

return: string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
param: int $id Post ID.
param: string $taxonomy Taxonomy name.
param: string $before Optional. Before list.
param: string $sep Optional. Separate items using this.
param: string $after Optional. After list.

get_term_parents_list( $term_id, $taxonomy, $args = array()   X-Ref
Retrieve 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 {

the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' )   X-Ref
Display the terms in a list.

return: false|void False on WordPress error.
param: int $id Post ID.
param: string $taxonomy Taxonomy name.
param: string $before Optional. Before list.
param: string $sep Optional. Separate items using this.
param: string $after Optional. After list.

has_category( $category = '', $post = null )   X-Ref
Check if the current post has any of given category.

return: bool True if the current post has any of the given categories (or any category, if no category specified).
param: string|int|array $category Optional. The category name/term_id/slug or array of them to check for.
param: int|object $post Optional. Post to check instead of the current post.

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.

Prior to v2.7 of WordPress, tags given as integers would also be checked against the post's tags' names and slugs (in addition to term_ids)
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 has any of the given tags (or any tag, if no tag specified).
param: string|int|array $tag Optional. The tag name/term_id/slug or array of them to check for.
param: int|object $post Optional. Post to check instead of the current post. (since 2.7.0)

has_term( $term = '', $taxonomy = '', $post = null )   X-Ref
Check 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 tags (or any tag, if no tag specified).
param: string|int|array $term Optional. The term name/term_id/slug or array of them to check for.
param: string $taxonomy Taxonomy name
param: int|object $post Optional. Post to check instead of the current post.



Generated: Wed Nov 21 08:20:01 2018 Cross-referenced by PHPXref 0.7