I've done some research and run up with this code
remove_action('wp_head','noindex',1);
but apparently it's not removing the <meta name="robots" content="noindex,follow"/>
in my WordPress header. I'm using WordPress 4.2.3
I've done some research and run up with this code
remove_action('wp_head','noindex',1);
but apparently it's not removing the <meta name="robots" content="noindex,follow"/>
in my WordPress header. I'm using WordPress 4.2.3
Use the wp_robots hook introduced in WordPress 5.7.0 to filter its robots meta tag output.
Sample function:
add_filter( 'wp_robots', 'wp_robots_remove_noindex', 999 );
function wp_robots_remove_noindex( $robots ){
//put any conditionals here to target certain pages
if ( is_search() || is_archive( ) || is_404( ) ) {
//set the index and noindex array items
$robots[ 'index' ] = true;
$robots[ 'noindex' ] = false;
}
return $robots;
}
This results in the following output:
<meta name='robots' content='index, follow' />
rankmath seo use this code To completely remove the ‘robots’ meta tag you can use the following filter:
add_filter( 'rank_math/frontend/robots', function( $robots ){return [];
});
Hope that helps. If you have questions, please ask. We are here to help.
More read
Log in to your WordPress website.
When you're logged in, you will be in your 'Dashboard'.
Click on 'Settings'. On the left-hand side, you will see a menu. ...
Click on 'Reading'. ...
UnCheck 'Discourage search engines from indexing this site'.
Click 'Save Changes'.
I will show you how to remove meta name='robots' content='noindex nofollow' in WordPress using replace some code inside the admin panel.
Step 1 - public_html → wp-includes → general-template.php
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 find file and type general-template.php.
Step 2 - Edit Two function
- First Code function Find:
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";
}
- First Code replace with bellow
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";
}
- Second Code function Find:
function wp_sensitive_page_meta() {
?>
<meta name='robots' content='noindex,noarchive' />
<meta name='referrer' content='strict-origin-when-cross-origin' />
<?php
}
- Second Code replaces with bellow:
function wp_sensitive_page_meta() {
?>
<meta name='robots' content='index,archive' />
<meta name='referrer' content='strict-origin-when-cross-origin' />
<?php
}