最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

templates - Removing calls to noindex() and wp_no_robots()

programmeradmin1浏览0评论

In the general-template.php file, I have functions (see below – "noindex" & "no robots") that are not allowing Google bots to index the website. I am trying to find the code where these functions are used. I looked into many files but I can't seem to find which file is using this code or where these functions are called from.

I need to remove these functions from where they are used in WordPress code. I have tried to remove the code from the general-template.php file but then it started to give me an error. So, I am pretty sure that I can't just delete them here; I need to remove the functions where they are used in other files of the WordPress code.

Any idea how I can do this?

/**
* Display a noindexmeta tag if required by the blog configuration.
*
* If a blog is marked as not being public then the noindexmeta tag will be
* output to tell web robots not to index the page content. Add this to the wp_head action.
* Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
*
* @see wp_no_robots
*
* @since 2.1.0
*/
function noindex() {
    // If the blog is not public, tell robots to go away.
    if ( '0' == get_option('blog_public') )
        wp_no_robots();
}
/**
* Display a noindexmeta tag.
*

In the general-template.php file, I have functions (see below – "noindex" & "no robots") that are not allowing Google bots to index the website. I am trying to find the code where these functions are used. I looked into many files but I can't seem to find which file is using this code or where these functions are called from.

I need to remove these functions from where they are used in WordPress code. I have tried to remove the code from the general-template.php file but then it started to give me an error. So, I am pretty sure that I can't just delete them here; I need to remove the functions where they are used in other files of the WordPress code.

Any idea how I can do this?

/**
* Display a noindexmeta tag if required by the blog configuration.
*
* If a blog is marked as not being public then the noindexmeta tag will be
* output to tell web robots not to index the page content. Add this to the wp_head action.
* Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
*
* @see wp_no_robots
*
* @since 2.1.0
*/
function noindex() {
    // If the blog is not public, tell robots to go away.
    if ( '0' == get_option('blog_public') )
        wp_no_robots();
}
/**
* Display a noindexmeta tag.
*
Share Improve this question edited Jan 29, 2016 at 6:43 Gabriel 2,24810 gold badges22 silver badges24 bronze badges asked Jan 29, 2016 at 6:32 PriyankaPriyanka 14 bronze badges 1
  • It's not a good idea to edit the core files. Why can't you just disable/enable the robots from the Dashboard? – denis.stoyanov Commented Jan 29, 2016 at 6:45
Add a comment  | 

1 Answer 1

Reset to default 1

Why you are changing the code for these thing which are able done via dashboard.?

WordPress comes with a built-in feature that allows you to instruct search engines not to index your site. All you need to do is visit Settings » Reading and check the box next to Search Engine Visibility option.

When this box is checked, WordPress adds this line to your website’s header:

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

WordPress also modifies your site’s robots.txt file and add these lines to it:

User-agent: *
Disallow: /

These lines ask robots (web crawlers) not to index your pages. However, it is totally up to search engines to accept this request or ignore it. Even though most search engines respect this, some page or random image from your site may get indexed.

发布评论

评论列表(0)

  1. 暂无评论