so I wanted to change the <title>
head element and found this post: Change the_title() of a page dynamically
I followed and my function now looks like this:
# set title per page
function vendor_module_filter_the_title($title)
{
# exclude menus
if (!in_the_loop()) {return $title;}
# collection page
if (is_page_template('page-collection.php')) {
if (strpos($_SERVER['REQUEST_URI'], 'category1') !== false) {
$title = 'title 1';
} else if (strpos($_SERVER['REQUEST_URI'], 'category2') !== false) {
$title = 'title 2';
}
}
return $title;
}
add_filter('the_title', 'vendor_module_filter_the_title', 10, 2);
however after CTRL + F5 it doesn't seem to work, I've tested with other meta tags using add_action('wp_head', ...)
but it doesn't seem to work for title using add_filter
- how do I go about debugging? How do I find out why this function doesn't work?
where am I going wrong? :/