Viktor:

I’m trying to apply the same function to the TITLE tag; however, it does not work at all.

I used the following code:
$category['title'] = str_replace('{CATEGORY_NAME}', $parent_category ? $category['name'] : '', $category['title']);

Would you please give some recommendations?