2016-12-07 1 views
1

Я пытаюсь изменить тег title, добавляя переменную (товарный бренд), но переменная не отображается.Изменить название тега с фильтром wpseo_title

add_filter('wpseo_title', 'filter_product_wpseo_title'); 
    function filter_product_wpseo_title() { 
     return 'hello'. $_GET[$mysite_slugs['product-brand']] .'hello'; 
    }; 
} 

попытался Также это, но не повезло

add_filter('wpseo_title', 'filter_product_wpseo_title'); 
    function filter_product_wpseo_title() { 
      $productbrand = $_GET[$mysite_slugs['product-brand']]; 
      return 'hello'. $productbrand .'hello'; 
    }; 
} 

ответ

0

Я предполагаю, что ваш URL имеет параметр .com/?product-brand=foo. Убедитесь, что вы добавили приоритет в свой фильтр. Это должно сделать трюк!

add_filter('wpseo_title', 'filter_product_wpseo_title', 10, 1); 

function filter_product_wpseo_title($title) { 
    $title = 'hello '. $_GET['product-brand'] .' hello'; 
    return $title; 
} 
Смежные вопросы