2 added 1 character in body; edited tags
source | link

I want to show the category name of the post when I write [category] shortcode in the post body. I'm using this code but only showing array error.

Sorry, I'm not an expert in coding. Perhaps you can redefine my code? Please.

function cat_post() {
    return get_the_category();
}
add_shortcode('categorypost', 'cat_post');

I want to show the category name of the post when I write [category] shortcode in the post body. I'm using this code but only showing array error.

Sorry, I'm not an expert in coding. Perhaps you can redefine my code? Please.

function cat_post(){
    return get_the_category();
}
add_shortcode('categorypost', 'cat_post');

I want to show the category name of the post when I write [category] shortcode in the post body. I'm using this code but only showing array error.

Sorry, I'm not an expert in coding. Perhaps you can redefine my code? Please.

function cat_post() {
    return get_the_category();
}
add_shortcode('categorypost', 'cat_post');
1
source | link

I want to show category name when using [category] shortcode

I want to show the category name of the post when I write [category] shortcode in the post body. I'm using this code but only showing array error.

Sorry, I'm not an expert in coding. Perhaps you can redefine my code? Please.

function cat_post(){
    return get_the_category();
}
add_shortcode('categorypost', 'cat_post');