• Resolved Daniel Chase

    (@riseofweb)


    Is there some kind of nuclear option to just completely remove this meta tag from a specific page or search results?
    <meta name='robots' content='follow, noindex' />

    Here is what I have been trying with no success:

    function indexSearch() {
    	if( is_search()) {
    		//add_filter( 'wpseo_robots', '__return_false', 10, 1 ); // this used to be what I used for the Yoast Plugin
    		add_filter( 'wp_robots_no_robots', '__return_false', 10, 1 );
    		remove_filter( 'wp_robots', 'wp_robots_noindex_search' );
    		add_filter( 'wp_robots', '__return_false', 10, 1 );
    		remove_filter( 'wp_robots', 'wp_robots_no_robots' );
    	}
    }
    add_action( 'wp', 'indexSearch' );

    Thanks in advance for any help.

    • This topic was modified 3 years, 8 months ago by Daniel Chase. Reason: Updated title
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Try adding a callback to “wp_robots” filter which returns an empty array(). Use a very large priority argument to help ensure your callback executes last.

    If you only want to do so for certain pages, conditionally return either the passed array or an empty array depending on what you want.

    Thread Starter Daniel Chase

    (@riseofweb)

    Thank you @bcworkz for the guidance.

    Here is the code that worked for me to remove the meta tag entirely:

    add_filter( 'wp_robots', array(), PHP_INT_MAX );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘meta robots, wp_robots, and search results pages with noindex’ is closed to new replies.