【问题标题】:Change title tag with filter wpseo_title使用过滤器 wpseo_title 更改标题标签
【发布时间】:2017-04-22 01:47:49
【问题描述】:

我正在尝试更改标题标签添加一个变量(产品品牌),但该变量没有显示出来。

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';
    };
}

【问题讨论】:

    标签: php seo title


    【解决方案1】:

    我假设您的网址具有参数.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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-29
      • 1970-01-01
      • 2020-09-05
      • 2019-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-17
      相关资源
      最近更新 更多