/wp-includes/category-template.php

Description

Category Template Tags and API.

Classes
Class Description
Walker_Category Create HTML list of categories.
Walker_CategoryDropdown Create HTML dropdown list of Categories.
Functions
category_description (line 261)

Retrieve category description.

  • return: Category description, available.
  • since: 1.0.0
string category_description ([int $category = 0])
  • int $category: Optional. Category ID. Will use global category ID by default.
default_topic_count_scale (line 572)

Default topic count scaling for tag links

  • return: scaled count
integer default_topic_count_scale (integer $count)
  • integer $count: number of posts with that tag
default_topic_count_text (line 562)

Default text for tooltip for tag links

  • return: text for the tooltip of a tag link.
string default_topic_count_text (integer $count)
  • integer $count: number of posts with that tag
get_category_link (line 18)

Retrieve category link URL.

  • return: Link on success, empty string if category does not exist.
  • see: get_term_link()
  • since: 1.0.0
string get_category_link (int|object  $category)
  • int|object $category: Category ID or object.
get_category_parents (line 42)

Retrieve category parents with separator.

  • since: 1.2.0
string get_category_parents (int $id, [bool $link = false], [string $separator = '/'], [bool $nicename = false], [array $visited = array()])
  • int $id: Category ID.
  • bool $link: Optional, default is false. Whether to format with link.
  • string $separator: Optional, default is '/'. How to separate categories.
  • bool $nicename: Optional, default is false. Whether to use nice name for display.
  • array $visited: Optional. Already linked to categories to prevent duplicates.
get_tag_link (line 964)

Retrieve the link to the tag.

  • return: Link on success, empty string if tag does not exist.
  • see: get_term_link()
  • since: 2.3.0
string get_tag_link (int|object  $tag)
  • int|object $tag: Tag ID or object.
get_the_category (line 74)

Retrieve post categories.

  • since: 0.71
  • uses: $post
array get_the_category ([int $id = false])
  • int $id: Optional, default to current post ID. The post ID.
get_the_category_by_ID (line 136)

Retrieve category name based on category ID.

  • return: Category name.
  • since: 0.71
string get_the_category_by_ID (int $cat_ID)
  • int $cat_ID: Category ID.
get_the_category_list (line 154)

Retrieve category list in either HTML list or custom format.

  • since: 1.5.1
string get_the_category_list ([string $separator = ''], [string $parents = ''], [int $post_id = false])
  • string $separator: Optional, default is empty string. Separator for between the categories.
  • string $parents: Optional. How to display the parents.
  • int $post_id: Optional. Post ID to retrieve categories.
get_the_tags (line 985)

Retrieve the tags for a post.

  • since: 2.3.0
  • uses: apply_filters() - Calls 'get_the_tags' filter on the list of post tags.
array get_the_tags ([int $id = 0])
  • int $id: Post ID.
get_the_tag_list (line 1001)

Retrieve the tags for a post formatted as a string.

  • since: 2.3.0
  • uses: apply_filters() - Calls 'the_tags' filter on string list of tags.
string get_the_tag_list ([string $before = ''], [string $sep = ''], [string $after = ''], [int $id = 0])
  • string $before: Optional. Before tags.
  • string $sep: Optional. Between tags.
  • string $after: Optional. After tags.
  • int $id: Optional. Post ID. Defaults to the current post.
get_the_terms (line 1061)

Retrieve the terms of the taxonomy that are attached to the post.

  • return: False on failure. Array of term objects on success.
  • since: 2.5.0
array|bool get_the_terms (int $id, string $taxonomy)
  • int $id: Post ID.
  • string $taxonomy: Taxonomy name.
get_the_term_list (line 1099)

Retrieve a post's terms as a list with specified format.

  • since: 2.5.0
string get_the_term_list (int $id, string $taxonomy, [string $before = ''], [string $sep = ''], [string $after = ''])
  • int $id: Post ID.
  • string $taxonomy: Taxonomy name.
  • string $before: Optional. Before list.
  • string $sep: Optional. Separate items using this.
  • string $after: Optional. After list.
has_category (line 1150)

Check if the current post has any of given category.

  • return: True if the current post has any of the given categories (or any category, if no category specified).
  • since: 3.1.0
bool has_category ([string|int|array $category = ''], [int|object  $post = null])
  • string|int|array $category: Optional. The category name/term_id/slug or array of them to check for.
  • int|object $post: Optional. Post to check instead of the current post.
has_tag (line 1171)

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

  • return: True if the current post has any of the given tags (or any tag, if no tag specified).
  • since: 2.6.0
bool has_tag ([string|int|array $tag = ''], [int|object  $post = null])
  • string|int|array $tag: Optional. The tag name/term_id/slug or array of them to check for.
  • int|object $post: Optional. Post to check instead of the current post. (since 2.7.0)
has_term (line 1189)

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: True if the current post has any of the given tags (or any tag, if no tag specified).
  • since: 3.1.0
  • usedby: has_post_format()
bool has_term ([string|int|array $term = ''], [string $taxonomy = ''], [int|object  $post = null])
  • string|int|array $term: Optional. The term name/term_id/slug or array of them to check for.
  • string $taxonomy: Taxonomy name
  • int|object $post: Optional. Post to check instead of the current post.
in_category (line 233)

Check if the current post in 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.

  • return: True if the current post is in any of the given categories.
  • since: 1.2.0
bool in_category (int|string|array $category, [int|object  $post = null])
  • int|string|array $category: Category ID, name or slug, or array of said.
  • int|object $post: Optional. Post to check instead of the current post. (since 2.7.0)
tag_description (line 1029)

Retrieve tag description.

  • return: Tag description, available.
  • since: 2.8
string tag_description ([int $tag = 0])
  • int $tag: Optional. Tag ID. Will use global tag ID by default.
term_description (line 1042)

Retrieve term description.

  • return: Term description, available.
  • since: 2.8
string term_description ([int $term = 0], [string $taxonomy = 'post_tag'])
  • int $term: Optional. Term ID. Will use global term ID by default.
  • string $taxonomy: Optional taxonomy name. Defaults to 'post_tag'.
the_category (line 249)

Display the category list for the post.

  • since: 0.71
void the_category ([string $separator = ''], [string $parents = ''], [int $post_id = false])
  • string $separator: Optional, default is empty string. Separator for between the categories.
  • string $parents: Optional. How to display the parents.
  • int $post_id: Optional. Post ID to retrieve categories.
the_tags (line 1015)

Retrieve the tags for a post.

  • since: 2.3.0
string the_tags ([string $before = null], [string $sep = ', '], [string $after = ''])
  • string $before: Optional. Before list.
  • string $sep: Optional. Separate items using this.
  • string $after: Optional. After list.
the_terms (line 1132)

Display the terms in a list.

  • return: False on WordPress error. Returns null when displaying.
  • since: 2.5.0
null|bool the_terms (int $id, string $taxonomy, [string $before = ''], [string $sep = ', '], [string $after = ''])
  • int $id: Post ID.
  • string $taxonomy: Taxonomy name.
  • string $before: Optional. Before list.
  • string $sep: Optional. Separate items using this.
  • string $after: Optional. After list.
walk_category_dropdown_tree (line 748)

Retrieve HTML dropdown (select) content for category list.

  • see: Walker_CategoryDropdown::walk() for parameters and return description.
  • since: 2.1.0
  • uses: Walker_CategoryDropdown - to create HTML dropdown content.
void walk_category_dropdown_tree ()
walk_category_tree (line 730)

Retrieve HTML list content for category list.

  • see: Walker_Category::walk() for parameters and return description.
  • since: 2.1.0
  • uses: Walker_Category - to create HTML list content.
void walk_category_tree ()
wp_dropdown_categories (line 299)

Display or retrieve the HTML dropdown list of categories.

The list of arguments is below: 'show_option_all' (string) - Text to display for showing all categories. 'show_option_none' (string) - Text to display for showing no categories. 'orderby' (string) default is 'ID' - What column to use for ordering the categories. 'order' (string) default is 'ASC' - What direction to order categories. 'show_count' (bool|int) default is 0 - Whether to show how many posts are in the category. 'hide_empty' (bool|int) default is 1 - Whether to hide categories that don't have any posts attached to them. 'child_of' (int) default is 0 - See get_categories(). 'exclude' (string) - See get_categories(). 'echo' (bool|int) default is 1 - Whether to display or retrieve content. 'depth' (int) - The max depth. 'tab_index' (int) - Tab index for select element. 'name' (string) - The name attribute value for select element. 'id' (string) - The ID attribute value for select element. Defaults to name if omitted. 'class' (string) - The class attribute value for select element. 'selected' (int) - Which category ID is selected. 'taxonomy' (string) - The name of the taxonomy to retrieve. Defaults to category.

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: HTML content only if 'echo' argument is 0.
  • since: 2.1.0
string wp_dropdown_categories ([string|array $args = ''])
  • string|array $args: Optional. Override default arguments.
wp_generate_tag_cloud (line 607)

Generates a tag cloud (heatmap) from provided data.

The text size is set by the 'smallest' and 'largest' arguments, which will use the 'unit' argument value for the CSS text size unit. The 'format' argument can be 'flat' (default), 'list', or 'array'. The flat value for the 'format' argument will separate tags with spaces. The list value for the 'format' argument will format the tags in a UL HTML list. The array value for the 'format' argument will return in PHP array type format.

The 'tag_cloud_sort' filter allows you to override the sorting. Passed to the filter: $tags array and $args array, has to return the $tags array after sorting it.

The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'. The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC' or 'RAND'.

The 'number' argument is how many tags to return. By default, the limit will be to return the entire tag cloud list.

The 'topic_count_text_callback' argument is a function, which given the count of the posts with that tag returns a text for the tooltip of the tag link.

  • todo: Complete functionality.
  • since: 2.3.0
string wp_generate_tag_cloud (array $tags, [string|array $args = ''])
  • array $tags: List of tags.
  • string|array $args: Optional, override default arguments.
wp_list_categories (line 412)

Display or retrieve the HTML list of categories.

The list of arguments is below: 'show_option_all' (string) - Text to display for showing all categories. 'orderby' (string) default is 'ID' - What column to use for ordering the categories. 'order' (string) default is 'ASC' - What direction to order categories. 'show_count' (bool|int) default is 0 - Whether to show how many posts are in the category. 'hide_empty' (bool|int) default is 1 - Whether to hide categories that don't have any posts attached to them. 'use_desc_for_title' (bool|int) default is 1 - Whether to use the description instead of the category title. 'feed' - See get_categories(). 'feed_type' - See get_categories(). 'feed_image' - See get_categories(). 'child_of' (int) default is 0 - See get_categories(). 'exclude' (string) - See get_categories(). 'exclude_tree' (string) - See get_categories(). 'echo' (bool|int) default is 1 - Whether to display or retrieve content. 'current_category' (int) - See get_categories(). 'hierarchical' (bool) - See get_categories(). 'title_li' (string) - See get_categories(). 'depth' (int) - The max depth.

  • return: HTML content only if 'echo' argument is 0.
  • since: 2.1.0
string wp_list_categories ([string|array $args = ''])
  • string|array $args: Optional. Override default arguments.
wp_tag_cloud (line 521)

Display tag cloud.

The text size is set by the 'smallest' and 'largest' arguments, which will use the 'unit' argument value for the CSS text size unit. The 'format' argument can be 'flat' (default), 'list', or 'array'. The flat value for the 'format' argument will separate tags with spaces. The list value for the 'format' argument will format the tags in a UL HTML list. The array value for the 'format' argument will return in PHP array type format.

The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'. The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.

The 'number' argument is how many tags to return. By default, the limit will be to return the top 45 tags in the tag cloud list.

The 'topic_count_text_callback' argument is a function, which, given the count of the posts with that tag, returns a text for the tooltip of the tag link.

The 'exclude' and 'include' arguments are used for the get_tags() function. Only one should be used, because only one will be used and the other ignored, if they are both set.

  • return: Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
  • since: 2.3.0
array wp_tag_cloud ([array|string $args = ''])
  • array|string $args: Optional. Override default arguments.

Documentation generated on Tue, 15 May 2012 23:17:43 +0000 by phpDocumentor 1.4.1