Is it possible to get the category name of a category given the Post ID, the following code works to get the Category Id, but how can I get the name?
<?php $post_categories = wp_get_post_categories( 4 ); echo $post_categories[0]?>
Thank!
Is it possible to get the category name of a category given the Post ID, the following code works to get the Category Id, but how can I get the name?
<?php $post_categories = wp_get_post_categories( 4 ); echo $post_categories[0]?>
Thank!
here you go
get_the_category( $post->ID );
will return the array of categories of that post you need to loop through the arrayget_the_category
doesn't
do just that, inside the loop?
For outside:
Use
get_the_category()
function.Here is the second argument of function
wp_get_post_categories()
which you can pass the attributes of receiving data.is what you maybe looking for.