1

enter image description here

How to add Category name to post title ? “PostTitle + CategoryName”?

1

You can use the function wp_get_post_categories to loop over the posts categories.

See Wordpress Docs for more info

1

You can use <?php the_category();?> function to retreive the name of the category.

Using a hook provided by your theme you can place the above function next to the post title.

Example -

`function catname() { echo the_category(); }

add_action('after_post_title','catname',10);`

This is just an example code.

If not hook then maybe you need to add it to the single post template using a child theme next to the post title i.e the_title();

https://developer.wordpress.org/reference/functions/the_category/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.