• Resolved charlieve02

    (@charlieve02)


    Hi

    For some reason google is indexing pages with this url ending:

    /?pp=1

    /feed/

    Searching through internet I found similar cases that you helped fixing by using this code:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    	$url = home_url( $_SERVER['REQUEST_URI'] );
    	if( (strpos($url,"?pp=") !== false) )  {
    		$robots["index"] = 'noindex';
    		$robots["follow"] = 'nofollow';
    	}
    	return $robots;
    });
    add_action( 'template_redirect', 'noindex_feeds' );
    function noindex_feeds() {
        if ( ! is_feed() ) {
            return;
        }
    header( 'X-Robots-Tag: noindex', true );

    I put this code in a rank-math.php file that I created in my child theme folder. But after saving, it puts all this code at the top of my page. And when I go to wp-admin to login I get a white page and the code at top.

    You can see this problem in these screenshots:

    https://privatebin.support-tools.com/?05d7ec9548deadbf#wcQ0H8OOS7MPUI9MABJyizoz2PQHVxBurl7VPHbK9ns=

    https://privatebin.support-tools.com/?7d56a55baa25eb27#+9BLW7TAK/DxK01MH2HeeLoHw5rWeUvURdDLkDC60cc=

    I removed the code for the moment because its affecting negatively my site.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘No index code issue’ is closed to new replies.