user186585
user186585

Reputation: 512

changing yoast title using wpseo_title function

I'm trying to set the title of the page (made by custom theme) This is my code, but for some reason it not getting the "$forumId" parameter

$forumId=999;
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title() {
        return 'My id= '. $forumId  ;
}

Upvotes: 0

Views: 1793

Answers (1)

user4055330
user4055330

Reputation:

You need to set $forumId as global variable. See updated code below.

global $forumId;
$forumId=999;
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title() {
        global $forumId;
        return 'My id= '. $forumId  ;
}

Upvotes: 2

Related Questions