pages – Add string to gage title if post in category wordpress

Question

Can someone please help me add a string to WP page title depending on category of a post ?

I did this with post title (code below) however I want to extend it to page title.

function recipe_titles ($title, $id=null) {
if (in_category (‘recipes’, $id)) {
$title = “Recept: ” .$title;
}
return $title;

}

add_filter (‘the_title’, ‘recipe_titles’,10,2);

0
TBV Translation 4 months 2022-08-03T03:18:45-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse