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>
Incoming search terms:
- how to get category name in wordpress by post id
- get the category id from post id
- find category name where post id in wordpress
- wordpress category id javascript
- wordpress get cat name by post id
- wordpress get category by post id
- wordpress get category id by post id
- wordpress get category id from post id php
- wordpress get the first category name of post
- wordpress get the next article by post id and cat id
- wordpress get_category_name
- wordpress simple php get category
- wp get post from category id
- wordpress api get post categories
- show category name of a particular post id
- get cat id current post
- get category from post id
- get category name wordpress
- get current post category id
- get post category id







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
Where may I experience monetary value of segments as well as repairs as Audi A3 2007? I’m reasoning of buying an Audi A3 2007 2.0 FSI , usually aspirated. I’d likes To acknowledge where I may experience actual info by what this may price how to repari if A/C broke down, or To substitute shocks, repair a console etc etc. also if everyone thinks this is a capital eating car to grounds of repairs Please let me recognise also. Many thanks
Intriguing post. I have been searching for some good resources for solar panels and discovered your blog. Planning to bookmark this one!
I’ve been checking your blog for a while now, seems like everyday I learn something new
Thanks
I REALLY liked your post and blog! It took me a minute bit to find your site…but I bookmarked it. Would you mind if I posted a link back to your post?
Thanks for the hack. This is exactly what I was looking for. An example and css styling would have made the post much more useful. I need to get the first category of the post on homepage. This will definitely help me out.
$categories = get_the_category($post->ID);
$currentcat = $category[0]->cat_name;
Hey clever monkey ! other clever monkeys might like your post but php doesnt Undefined variable: category in /home/testsev/public_html