WordPress Title Tag in Page Functions.php code gone wrong

I want to display dynamic title tag for a certain page.

The title tag will be made of 2 parts:

Read More
  1. Parameter cat_param i.e. abc.com/?cat_param=
  2. 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' );

Related posts

1 comment

  1. With Reigel’s help and guidance, I managed to get a workable code:

    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' );
    

Comments are closed.