2016-11-17 62 views
0

我試圖設置頁面的標題改變yoast標題(自定義主題製造) 這是我的代碼,但由於某種原因,沒有得到「$ forumId」參數使用wpseo_title功能

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

回答

2

您需要將$ forumId設置爲全局變量。查看下面的更新代碼。

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