Many people want to know about post category and know more information current category.
Some time we need to use the first category of wordpress post. As we know we can define the multiple category to single article. So if we want retrive the wordpress category then we will get the result in simple php array format. Using that array we can easily extract the first category of post.
In this post I will show how we can achieve that. Using following code we can get the first category ID.
< ?php $category = get_the_category(); $currentcat = $category[0]->cat_ID; ?>
Using following code we can extract the first category name from the wordpress post.
< ?php $category = get_the_category(); $currentcat = $category[0]->cat_name; ?>
Above code we can use only in the loop but using the following code we can extract the category
outside the loop also
<?php global $post; $categories = get_the_category($post->ID); $currentcat = $category[0]->cat_ID; ?> <pre>
same like that.. cat name
<?php global $post; $categories = get_the_category($post->ID); $currentcat = $category[0]->cat_name; ?> <pre>




Amazing site, where did you come up with the information in this summary? Im glad I found it though, ill be checking back soon to see what other articles you have.
Good, your blog very useful for me, i will book mark it, thanks!
This is a outstanding post, but I was wondering how do I suscribe to the RSS feed?
Please click on right side email icon for subscribe the RSS feed.
Can I make a suggestion? I think youve got something good here. But what if you added a couple links to a page that backs up what youre saying? Or maybe you could give us something to look at, something that would connect what youre saying to something tangible? Just a suggestion.
I was searching for How to get a book published in Canada, and found your website. Very thoughtfull.It should be very much helpfull. Thanks for information!
Hey, often excellent to see other folks through the hole world in my searching, I really appreciate the time it should have taken to put together this cool site. best regards