我为我的一个客户做SEO,我们使用一个插件来展示汽车,从Mobile.de获得数据。
现在这个插件取了汽车的名字。“日产X 1.75 dCi 4x4 AT TEKNA BOSE+STANDHEIZ+AHK”,并将wordpress博客的名字放在它后面。这是网址,如果有帮助的话:https://kallies-automobile.de/
我想去掉博客名,并尝试使用str_replace函数
add_filter(DXIM_FILTER_VEHICLE_SINGLE_PAGE_TITLE,function($title, $vehicle) {
$title = str_replace('- Kallies Automobile e.K. | Einfach. Sicher. Autofahren. ✔️', '', $title); {
}
return $title;
},10,2);但根本不起作用。我很高兴得到输入!
发布于 2022-04-21 13:01:49
看起来您使用的是Yoast,因此在这方面,您需要使用Yoast页面标题筛选器:
add_filter('wpseo_title', 'filter_post_title');
function filter__title($title) {
if( is_singular( 'fahrzeugangebot' ) ) {
$title = str_replace('- Kallies Automobile e.K. | Einfach. Sicher. Autofahren. ✔️', '', $title);
}
return $title;
}上面的过滤器检查我们是否在一个帖子类型的'fahrzeugangebot‘(抱歉,如果这不是你想要实现的),然后你投入的str_replace。
https://stackoverflow.com/questions/71953848
复制相似问题