0

I'm working on a Wordpress site built by someone else and found that this meta tag is on all pages:

<meta name='robots' content='noindex,follow' />

I need to edit this. I looked inside header.php, header-main.php, and header-single.php and didn't find it. Any idea what file it might be located in or how to locate it?

Ashley Liu
  • 453
  • 1
  • 7
  • 17
  • The "wp_no_robots" function is being called from wp_includes/function.php file. and the wp_no_robots() function is written in wp-includes/general-template.php file. – B-shan Jun 08 '20 at 04:59

4 Answers4

1

Access WordPress admin area and go to Settings and select Reading.There you will find an option called Search Engine Visibility. Check the box that says Discourage search engines from indexing this site. And Disable this.

dayan khan
  • 51
  • 3
  • This is the setting I'd been hunting high and low for! I recall while setting up Wordpress, I checked an option to tell search engines not to index the site and this is it. Thanks dayan! – Eugene Chow Feb 17 '23 at 09:45
1

Comment from Ashley Liu is correct - sometimes the problem is more insidious and the only solution is performing a site wide search for files calling wp_no_robots().

For some installations unchecking settings>reading>Search_Engine_Visibility does not have any effect as the wp_no_robots function might be called by some other code element.

As a result the site remains crippled to indexing by search engines. I have run into this problem and have spent hours trying to track down the function that calls the wp_no_robots() file.

Also, the majority of posts on this topic seem to imply that it is caused by some mysterious setting in Yoast SEO. However, my site does not use the the Yoast seo plugin. I suspect other users are facing this problem.

So I suggest, as a stop gap measure, doing the unthinkable and making a change to the wp_no_robots function in the general-template.php file to get your site indexed ASAP.

I found this code at this original post. It suggest that you change wp_no_robots() from:

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";

to:

    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";

Then after once again being found by google, you can begin the task of performing a global search using a utility with a "search in files" feature for files calling the wp_no_robots functions to see if anything seems out of place. (notepad++ has a file search feature).

Once the problem has been identified, make sure that you replace your modified general-template.php with your original backed up file.

pcummings
  • 11
  • 3
0

There might be a plugin which is inserting that line. to be more specific, check for any SEO related plugin which is a general candidate for this meta tag.

Anant Anand Gupta
  • 650
  • 1
  • 11
  • 22
0

The code is in almost 20 files in various forms in wp-includes, wp-content, and wp-admin. For anyone who runs into this problem, download a copy of your site, open the folder with an IDE with a "search in folder" function like Sublime, and search for both this meta tag code and a function called wp_no_robots(), which adds a "noidex" tag when it's called.

Ashley Liu
  • 453
  • 1
  • 7
  • 17