admin管理员组文章数量:1130349
I am storing the SEO title with advanced-custom-fields. How do i set the seo title tag within my single-mypost.php template. This is the place where i can call get_field('title_tag');
I tried adding this to functions.php :
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title($title) {
if( is_singular( 'my_post_type') ) {
$title = get_field("title_tag");
}
return $title;
}
I am storing the SEO title with advanced-custom-fields. How do i set the seo title tag within my single-mypost.php template. This is the place where i can call get_field('title_tag');
I tried adding this to functions.php :
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title($title) {
if( is_singular( 'my_post_type') ) {
$title = get_field("title_tag");
}
return $title;
}
Share
Improve this question
edited Dec 22, 2018 at 20:56
Tintinabulator Zea
asked Dec 22, 2018 at 5:43
Tintinabulator ZeaTintinabulator Zea
1298 bronze badges
2
- 2 And why don’t you just use one of SEO plugins? – Krzysiek Dróżdż Commented Dec 22, 2018 at 6:37
- 1 And...? You can still set it programmatically using Yoast SEO for example... – Krzysiek Dróżdż Commented Dec 22, 2018 at 19:01
1 Answer
Reset to default -1I added this to functions.php while having Yoast SEO activated, and then it worked!
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title($title) {
if( is_singular( 'my_post_type') ) {
$title = get_field("title_tag");
}
return $title;
}
I am storing the SEO title with advanced-custom-fields. How do i set the seo title tag within my single-mypost.php template. This is the place where i can call get_field('title_tag');
I tried adding this to functions.php :
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title($title) {
if( is_singular( 'my_post_type') ) {
$title = get_field("title_tag");
}
return $title;
}
I am storing the SEO title with advanced-custom-fields. How do i set the seo title tag within my single-mypost.php template. This is the place where i can call get_field('title_tag');
I tried adding this to functions.php :
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title($title) {
if( is_singular( 'my_post_type') ) {
$title = get_field("title_tag");
}
return $title;
}
Share
Improve this question
edited Dec 22, 2018 at 20:56
Tintinabulator Zea
asked Dec 22, 2018 at 5:43
Tintinabulator ZeaTintinabulator Zea
1298 bronze badges
2
- 2 And why don’t you just use one of SEO plugins? – Krzysiek Dróżdż Commented Dec 22, 2018 at 6:37
- 1 And...? You can still set it programmatically using Yoast SEO for example... – Krzysiek Dróżdż Commented Dec 22, 2018 at 19:01
1 Answer
Reset to default -1I added this to functions.php while having Yoast SEO activated, and then it worked!
add_filter('wpseo_title', 'filter_product_wpseo_title');
function filter_product_wpseo_title($title) {
if( is_singular( 'my_post_type') ) {
$title = get_field("title_tag");
}
return $title;
}
本文标签: custom post typesHow to set the seo title tag on a page by page basis
版权声明:本文标题:custom post types - How to set the seo title tag on a page by page basis? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749075040a2312170.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论