admin管理员组文章数量:1025840
Trying to remove the from a specific page so I don't have duplicates. Is there away to filter these out in the functions? I have already removed the canonical but wasn't able to reproduce the same with title using wp_title or wpseo_title.
function remove_canonical() {
if ( is_page(12891) ) {
add_filter( 'wpseo_canonical', '__return_false', 10, 1 );
add_filter( 'wpseo_title', '__return_false' );
add_filter( 'wp_title', '__return_false' );
}
}
add_action('wp', 'remove_canonical');
Trying to remove the from a specific page so I don't have duplicates. Is there away to filter these out in the functions? I have already removed the canonical but wasn't able to reproduce the same with title using wp_title or wpseo_title.
function remove_canonical() {
if ( is_page(12891) ) {
add_filter( 'wpseo_canonical', '__return_false', 10, 1 );
add_filter( 'wpseo_title', '__return_false' );
add_filter( 'wp_title', '__return_false' );
}
}
add_action('wp', 'remove_canonical');
Share
Improve this question
edited Mar 31, 2019 at 17:40
Krzysiek Dróżdż
25.6k9 gold badges53 silver badges74 bronze badges
asked Mar 31, 2019 at 17:17
JasonJason
1
4
|
1 Answer
Reset to default 0Removing the action is really what I intended as I'm not replacing the title. changing my last line to this works for what I was intending.
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
Trying to remove the from a specific page so I don't have duplicates. Is there away to filter these out in the functions? I have already removed the canonical but wasn't able to reproduce the same with title using wp_title or wpseo_title.
function remove_canonical() {
if ( is_page(12891) ) {
add_filter( 'wpseo_canonical', '__return_false', 10, 1 );
add_filter( 'wpseo_title', '__return_false' );
add_filter( 'wp_title', '__return_false' );
}
}
add_action('wp', 'remove_canonical');
Trying to remove the from a specific page so I don't have duplicates. Is there away to filter these out in the functions? I have already removed the canonical but wasn't able to reproduce the same with title using wp_title or wpseo_title.
function remove_canonical() {
if ( is_page(12891) ) {
add_filter( 'wpseo_canonical', '__return_false', 10, 1 );
add_filter( 'wpseo_title', '__return_false' );
add_filter( 'wp_title', '__return_false' );
}
}
add_action('wp', 'remove_canonical');
Share
Improve this question
edited Mar 31, 2019 at 17:40
Krzysiek Dróżdż
25.6k9 gold badges53 silver badges74 bronze badges
asked Mar 31, 2019 at 17:17
JasonJason
1
4
- By 'title`, are you thinking of the text that appears above the browser page (in or near the window frame, in the tab, etc.), or the headline that typically appears below the masthead and site navigation, and above the main content? – Loren Rosen Commented Apr 1, 2019 at 0:29
- The actual HTML title tag <title>stuff here</title> – Jason Commented Apr 1, 2019 at 12:14
-
The first two filters are Yoast things, and off-topic here. But I think returning
false
just disables them. Anyway, it probably doesn't matter. The last filter should return a string, so you probably want'__return_empty_string'
. That said, I might imagine that returning a non-string would have the same effect. But perhaps instead it has no effect at all (that is, the string is unchanged). If it still doesn't work, I'd try changing the priority. You want this to run last, so the priority number should be large. – Loren Rosen Commented Apr 1, 2019 at 15:13 - Well thinking through it I don't want to filter the result or replace it, I really want to disable it. remove_action( 'wp_head', '_wp_render_title_tag', 1 ); works perfectly in this instance. – Jason Commented Apr 1, 2019 at 15:51
1 Answer
Reset to default 0Removing the action is really what I intended as I'm not replacing the title. changing my last line to this works for what I was intending.
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
本文标签: filter out lttitlegt
版权声明:本文标题:filter out <title> 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745639454a2160653.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
false
just disables them. Anyway, it probably doesn't matter. The last filter should return a string, so you probably want'__return_empty_string'
. That said, I might imagine that returning a non-string would have the same effect. But perhaps instead it has no effect at all (that is, the string is unchanged). If it still doesn't work, I'd try changing the priority. You want this to run last, so the priority number should be large. – Loren Rosen Commented Apr 1, 2019 at 15:13