I want to display dynamic title tag for a certain page.
The title tag will be made of 2 parts:
- Parameter cat_param i.e. abc.com/?cat_param=
- Text eg. Outlet Las Vegas
Lets say the parameter cat_param= 24hours, the intended output is:
24hours Outlet Las Vegas
I have put the following code in my functions.php, but it didn’t work.
Kindly enlighten me which part of this code I should correct:
function change_tt( $title ) {
if ( is_page( 123 ) && isset( $_GET['cat_param'] ) ) {
$title = "$_GET[cat_param] 'Outlet Las Vegas'"
}
return $title;
}
add_filter( 'wp_title', 'change_tt' );
With Reigel’s help and guidance, I managed to get a workable code: