Removing “noindex, nofollow” from my

0
54

I have give different solution use any one

First solution  

i Developed an E commerce site for a client and i was stacked with this issue for more than a week, all pages were indexed except for the Home Page.

After a long debugging of Yoast Seo Plugin, i got a solution for you guys.

SOLUTION The Homepage has a search page on it (for searching for products). By default, Yoast disables ‘index’ meta tag for Search Page and 404 Page. funny enough if your homepage has a search page or search functionality on it, your site may not be indexed by google or any other search engine.

To fix this default by Yoast SEO Plugin, follow the following steps:

STEP 1: Log into your cpanel and navigate to /public_html/yourwebsite.com/wp-content/themes/nameOfTheTheme/functions.php add this line of code to your theme’s function.php file (at the top of the page)

 /**
  * EDITED BY OBOT ERNEST
  * REMOVES NOINDEX META TAG FROM HOME PAGE  & SEARCH PAGE IMPLEMENTED BY YOAST
 */


    add_filter('wpseo_robots', 'yoast_no_home_noindex', 999);
    function yoast_no_home_noindex($string= "") {
        if (is_home() || is_front_page() || is_search()) {
            $string= "index,follow";
        }
        return $string;
    }

After pasting the code, save and close file.

STEP 2 Note this second step is for those that are using any of the following SEO plugins (Yoast Premium, Yoast Free or wordpress-seo-premium plugin)

Navigate to: /public_html/youwebsite.com/wp-content/plugins/wordpress-seo-premium/frontend/class-frontend.php

replace the code at line 713 with this one below here:

    if ( is_search() ) {
$robots['index'] = 'index';
}
    if ( is_404() ) {
$robots['index'] = 'noindex';
}

Save file and close

Congratulations! you just made it. It working perfectly guys!

Second solution  

I found a solution that worked for me here

add_action( 'init', 'remove_wc_page_noindex' );
function remove_wc_page_noindex() {
    remove_action( 'wp_head', 'wc_page_noindex' );
}

Third only account page

I took a look at this again just now and couldn’t remove it either. Then I remembered my development site is set to discourage search engines so every page was set to noindex.

I turned that off and then worked with the snippets from the other thread a bit. This one works for me.


function ijab_account_noindex(){
	if ( is_page( get_option('woocommerce_myaccount_page_id') ) ) {
		remove_action( 'wp_head', 'wc_page_noindex' );
	}
	elseif((is_page(7) || is_page(8)))
	{remove_action( 'wp_head', 'wc_page_noindex' );}
	else{}
}
add_action( 'template_redirect', 'ijab_account_noindex' );

It leaves the noindex on the cart and checkout but removes it on the account page.

See if that works for you.

 

full and final if not change any where

How to Remove WordPress Robots Meta Tag noindex, nofollow

We will show you how to remove meta name=’robots’ content=’noindex nofollow’ in WordPress using replace some code inside the admin panel, no plugin request.

Step 1 – Log into your cPanel

Well, you log inside the public_html directory, now you find a folder, name wp-includes, double click to open this folder. At the same time, there are so many folders and files, take a breath, and simply click to your keyboard Ctrl+f and type general-template.php.

Step 2 – Edit general-template.php File

Find this code inside general-template.php

function wp_no_robots() {
if ( get_option( 'blog_public' ) ) {
    echo "<meta name='robots' content='noindex,follow' />\n";
    return;
}

echo "<meta name='robots' content='noindex,nofollow' />\n";

}

Replace first with this code:

function wp_no_robots() {
if ( get_option( 'blog_public' ) ) {
    echo "<meta name='robots' content='index,follow' />\n";
    return;
}
echo "<meta name='robots' content='index,follow' />\n";

}

2 – Find this second code same file general-template.php:

This

function wp_sensitive_page_meta() {
?>
<meta name='robots' content='noindex,noarchive' />
<meta name='referrer' content='strict-origin-when-cross-origin' />
<?php

}

Replace to

function wp_sensitive_page_meta() {
?>
<meta name='robots' content='index,archive' />
<meta name='referrer' content='strict-origin-when-cross-origin' />
<?php

}

Once that is complete, go back to the website check, change into Search Console, resubmit the URL you tried earlier. The URL inspection report should be void of all warnings and error messages, at least ones related to indexing and crawl ability, and you’ll be able to “Request Indexing,”.

one other way tye

add_action( 'wp_head', function() {
   if (is_page(7407) || is_page(7640) || is_page(7660)) {
        echo '';
    }
} );

LEAVE A REPLY

Please enter your comment!
Please enter your name here