0

For better understanding what I need, I'll give as example the image below. enter image description here

As you can see, on CAT LOVERS category, I have the full title as "Basic Health & Care Tips to Keep Your Cat Healthy".

Here I need to have a custom title like "Healthy Cat", on all pages (homepage, search results, tag, archive, author archives, etc) BUT keep the full title on single post page (Basic Health & Care Tips to Keep Your Cat Healthy).

There's an example:

enter image description here

I only need this for a specific category, Cat Lovers in this case.

Thank you.

1
  • Can you include your template code for the output? What you'd need to do is conditionally check for the category, then change what gets output depending on whether or not the category is present. Commented Feb 15 at 15:21

1 Answer 1

0

You can use the_title filter hook.

add_filter("the_title", function ($title) {

    if (!is_single() && !is_admin() && has_category("CAT LOVERS")) {
        return "Healthy Cat";
    }
    return $title;
});
2
  • I suppose that code will the same title (Healthy Cat) on ALL posts in Cat Lovers, right? How about for multiple/custom titles? Commented Feb 12 at 15:17
  • Still need some help here :( Commented Feb 13 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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