• Resolved rtenny

    (@rtenny)


    I have a plugin that handle property listings as custom post type.
    The robots meta gets handle by this plugin and I would like to exclude this post type from the YOAST robots function as I now have 2 conflicting robots meta tags.

    Can this be done? I have already changed the core files but after each update that change would get lost.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Maybe I can help you (I made something similar). You can use filter wpseo_robots:

    
    if ( class_exists('WPSEO_Frontend') ) {
          // Yoast SEO is active - add filter wpseo_robots
          
          add_filter( 'wpseo_robots', 'my_robots_func' );
          ....
    } else {
          // use other function
    }
    
    function my_robots_func( $robotsstr ) {
    	if ( is_singular( 'blabla' ) {
    		return 'noindex,follow';		
    	}
    	return $robotsstr;
    }
    

    I’m not sure that you want it or something else. Also, you have option in SEO dashboard to exclude some post_types. You can post more details on https://github.com/Yoast/wordpress-seo/issues and I’ll try to help you

    Thread Starter rtenny

    (@rtenny)

    Great, thx very much, Thats is just what I needed

    You saved me a whole day of work. Thank you a million!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude custom post from robots function’ is closed to new replies.