我已经在我的博客上安装了wordpress SEO Yoast插件。我想避免使用SEO生成的标题为我的博客。有任何方法,我可以删除过滤器,正在应用SEO插件的wp_title()?我想使用页面标题作为SEO标题。
add_filter( 'wp_title', 'te_before_filter_wp_title' );
function te_before_filter_wp_title( $title ) {
echo $title;
//exit;
return $title;
}
add_filter( 'wp_title', 'te_after_filter_wp_title' ,9999);
function te_after_filter_wp_title( $title ) {
echo $title;
//exit;
return $title;
}我编写了这段代码来测试标题。te_before_filter_wp_title和te_after_filter_wp_title中的标题是不同的。因此,它是由SEO插件修改。
发布于 2014-03-15 16:01:44
对于较早版本的WPSEO (v1~2),可以使用以下代码删除它应用的过滤器:
add_action( 'init', function() {
global $wpseo_front;
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
}, 20 );使用较新版本的WPSEO (~3+)和WordPress (4.4+),可以使用以下代码删除筛选器:
add_action( 'init', function () {
$wpseo_front = WPSEO_Frontend::get_instance();
remove_filter( 'pre_get_document_title', array( $wpseo_front, 'title' ), 15 );
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
} );https://stackoverflow.com/questions/22035426
复制相似问题