WordPress 中文文档
Function Reference/category description
出自WordPress Chinese 中文文档
wordpress.org.cn
目录 |
Description
Returns the description of a category defined in the category settings screen for the current category (Posts Categories).
Usage
%%% ?php echo category_description( $category ); ? %%%
Parameters
- $category
- (integer) The numeric ID of the category for which the tag is to return the description. Defaults to the current category, if one is not set.
Examples
Default Usage
Displays the description of a category, given its id, by echoing the return value of the tag. If no category given and used on a category page, it returns the description of the current category.
%%% div?php echo category_description(3); ?/div %%%
Result:
WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.
Note: if there is no category description, the function returns a br tag
Using Category Slug
Displays the description of a category, using a category slug.
%%% ?php echo category_description(get_category_by_slug('category-slug')-term_id); ? %%%
With Category Title
%%% divstrong?php single_cat_title('Currently browsing'); ? /strong: ?php echo category_description(); ?/div %%%
Result:
Currently browsing WordPress: WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.
Related
the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, get_the_category, get_category_parents, get_category_link, is_category, in_category
includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude
Description
This Template is used by Codex:Template Messages.
Usage
pre 已侦测回归模板: Template:Message /pre
Result
已侦测回归模板: Template:Message
/noinclude

