RSS

Show Category Name Tn The Current Post | Wordperss

Wed, Dec 23, 2009

WordPress

This is acturally for wordpress’s breadcrumb navagation, when we want to show the category for the current category, we can use the code below, just for record

<?php
foreach((get_the_category()) as $category) {
    echo $category->cat_name . ' ';
}
?>

and you can replace the cat_name to be other category factors below
cat_ID
the category id (also stored as ‘term_id’)
cat_name
the category name (also stored as ‘name’)
category_nicename
a slug generated from the category name (also stored as ’slug’)
category_description
the category description (also stored as ‘description’)
category_parent
the category id of the current category’s parent. ‘0′ for no parents. (also stored as ‘parent’)
category_count
the number of uses of this category (also stored as ‘count’)

we can also use the code from wordpress directly,
 <?php the_category(', '); ?>
 <?php the_title(); ?>

Incoming search terms for the article:

Related Posts

This post was written by:

Kent - who has written 274 posts on Kent’s Blog.

Working in the English Search Engine industry, focusing on the new media and new economy, Trying to find out a way for e-commerce integration!

Contact the author

2 Comments For This Post

  1. ppc management Says:

    Hi, I hope you don’t mind me posting here but I desperately need help. I’m advertising using Adwords, it used to be fine but it’s so expensive

  2. WPExplorer Says:

    Cool, this just helped me alot on my site.

Leave a Reply

Powered by Yahoo! Answers