使用 wpseo_title 函数更改酵母名称

changing yoast title using wpseo_title function

我正在尝试设置页面的标题(由自定义主题制作) 这是我的代码,但由于某种原因它没有获得“$forumId”参数

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

您需要将$forumId 设置为全局变量。请参阅下面的更新代码。

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