Please note that get_the_category() returns an array, which means that you can't directly echo the value returned.
Here is a list of objects of each category that you can print:
Code
$categories = get_the_category();
foreach( $categories as $category ) {
echo $category->name . '<br />';
}
Output
All names of categories of the current page, one on each line.
Code
$categories = get_the_category();
foreach( $categories as $category ) {
echo $category->term_id . '<br />';
}
Output
All ids of categories of the current page, one on each line.
Parameter | Details |
---|---|
$id | (int) (Optional) default to current post ID. The post ID. |