Category tags

1)category_description()

 Description
Returns the description of a category defined in the category settings screen for the current category (Posts > Categories).

If used in the archive.php template, place this function within the is_category() conditional statement. Otherwise, this function will stop the processing of the page for monthly and other archive pages.

Usage
 <?php echo category_description( $category_id ); ?>

Parameters
$category_id
(integer) (optional) The ID of the category to return a description.
Default: Description of current query category.

Example
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>

2)single_cat_title()

 Description
Retrieve the name of a category from its ID.

Usage
<?php get_cat_name( $cat_id ) ?>

Parameters
$cat_id
(integer) (required) Category ID
Default: None

Return Values
(string)
Category name

Examples
<?php echo get_cat_name(4);?>
returns the name for the category with the id '4'.

3)the_category()

 Description
Displays a link to the category or categories a post belongs to. This tag must be used within The Loop.

Usage
 <?php the_category( $separator, $parents, $post_id ); ?>

Parameters
$separator
(string) (optional) Text or character to display between each category link. By default, the links are       placed in an HTML unordered list. An empty string will result in the default behavior.
Default: empty string
$parents
(string) (optional) How to display links that reside in child (sub) categories. Options are:
 ▪ 'multiple' - Display separate links to parent and child categories, exhibiting "parent/child" relationship.
 ▪ 'single' - Display link to child category only, with link text exhibiting "parent/child" relationship.
Default: empty string
Note: Default is a link to the child category, with no relationship exhibited.
$post_id
(int) (optional) Post ID to retrieve categories. The default value false results in the category list of the current post.
Default: false

Examples
Separated by Space
List categories with a space as the separator. <?php the_category( ' ' ); ?>

Separated by Comma
Displays links to categories, each category separated by a comma (if more than one). <?php the_category( ', ' ); ?>

No comments:

Post a Comment

=>SEO

1.  Syllabus 2.  Unit Wise Question/Material 3. Paper 4. Previous Paper