php - Set noindex from template - Yoast -


with wordpress plugin's yoast seo it's possible set noindex, nofollow type of template i've create?

for example, i've custom template called "section", so, it's possible set noindex,nofollow default template yoast seo plugin, api yoast?

find this nothing noindex, nofollow functions.

for you, i've solved in way.

    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' ); 

Comments

Popular posts from this blog

c - zlib and gdi32 with OpenSSL? -

java - inputmismatch exception -

ios - Align baselines with characters in large line heights with Text Kit -