有了Wordpress插件的Yoast,就有可能设置noindex,而不是从我创建的某种模板中获得?
例如,我有自定义模板,我称之为“节”,所以,可以设置noindex,默认情况下使用Yoast SEO插件,甚至使用API Yoast?
查找这,但没有任何关于noindex、no追随者函数的内容。
发布于 2016-12-22 11:52:57
对你来说,我就这样解决了。
function set_noindex_nofollow($post_id){
if ( wp_is_post_revision( $post_id ) ) return;
if ( strpos(get_page_template_slug($post_id),'section') !== false){
add_action( 'wpseo_saved_postdata', function() use ( $post_id ) {
update_post_meta( $post_id, '_yoast_wpseo_meta-robots-noindex', '1' );
update_post_meta( $post_id, '_yoast_wpseo_meta-robots-nofollow', '1' );
}, 999 );
}else{
return;
}
}
add_action( 'save_post', 'set_noindex_nofollow' );https://stackoverflow.com/questions/40658304
复制相似问题