• Resolved ikvaesolutions

    (@ikvaesolutions)


    Previously we were using add_filter( 'wpseo_robots', '__return_false' ); to stop outputting robots meta in HTML.

    However, it stops working from the recent update. Now, it outputs <meta name='robots' content='noindex, nofollow' />

    When I return null for wpseo_robots filter, it outputs <meta name='robots' content='max-image-preview:large' />

    Is there any other way to completely stop outputting ‘robots’ meta in HTML?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    Before Yoast SEO v19.8, setting wpseo_robots to false was still outputting the robots meta but with the max-image-preview:large value on it.

    In the latest version of Yoast SEO, setting wpseo_robots to false now set the content value to noindex, nofollow.

    So, I doubt setting up wpseo_robots to false before disabling the robots meta completely on your site.

    That said, while I don’t have a solution to remove the robots meta completely from your website, I do know that it has no effect when there’s no value in the content key. So, you may want to return an empty string i.e., from the wpseo_robots filter to see whether it return an empty value for you in the robots meta.

    Thread Starter ikvaesolutions

    (@ikvaesolutions)

    I managed to achieve the previous version’s behavior with the following combination of filters.

    function ikva_remove_robots_meta() {
    	return null;
    }
    
    add_filter('wpseo_robots', 'ikva_remove_robots_meta');
    add_filter('wpseo_googlebot', 'ikva_remove_robots_meta');
    add_filter('wpseo_bingbot', 'ikva_remove_robots_meta');
    add_filter( 'wpseo_canonical', '__return_false' );
    remove_filter('wp_robots', 'wp_robots_max_image_preview_large');

    Hello,

    So it means that Yoast made an update which affects the custom handlers that were previously wisely shared by the WordPress community, changing the indexing behaviour ?

    Hopefully, I did not have critical content indexed or unindexed and @ikvaesolutions code snippets work like a charm to fix it again. Thanks!

    Hope we can rely on it for the long term and Yoast will care about its code update in the future. SEO is a serious game.

    I tried what @ikvaesolutions suggested and it worked, except for the last line.

    I tried

    remove_filter( 'wp_robots', 'wp_robots_max_image_preview_large' );

    and (below is OP original but wan’t sure if the spaces made a difference)

    remove_filter('wp_robots', 'wp_robots_max_image_preview_large')

    I still get <meta name='robots' content='max-image-preview:large' />

    Does anyone know how to remove the above line completely from the html?

    Thanks

    // Noindex filter queries
    function robotkaldirma() {
    	return null;
    }
    if (strpos($_SERVER['REQUEST_URI'], '?') !== false || strpos($_SERVER['REQUEST_URI'], '/feed') !== false) {
    
    add_filter('wpseo_robots', 'robotkaldirma');
    add_filter('wpseo_googlebot', 'robotkaldirma');
    add_filter('wpseo_bingbot', 'robotkaldirma');
    add_filter( 'wpseo_canonical', '__return_false' );
    remove_filter('wp_robots', 'wp_robots_max_image_preview_large');
    	function eklenofollow(){
    echo "<meta name='robots' content='noindex, nofollow'>";
    	}
    	add_action('wp_head','eklenofollow', 1,1);
    
    }
    
    
    
    

    if you add this code to your function.php file
    yoursite.com/subpage?example
    or
    yoursite.com/subpage/?example
    It will return with noindex tag

    If you visit a normal page url such as yoursite.com/yourpage
    meta robots tag that works like normal
    will return.
    index, follow how you set on yoast settings

    It’s not important. ??

    • This reply was modified 1 year, 6 months ago by emreinci.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Remove Robots Meta Tag Completely from HTML’ is closed to new replies.