2016-12-07 5 views
1

変数(商品ブランド)を追加するタイトルタグを変更しようとしていますが、変数が表示されません。タイトルタグをフィルタ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; 
} 
関連する問題