'Cannot remove action noindex in wordpress
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
Solution 1:[1]
? I found a solution that worked for me here: ? https://wordpress.org/support/topic/disable-noindex-on-certain-core-pages-2/
add_action( 'init', 'remove_wc_page_noindex' );
function remove_wc_page_noindex(){
remove_action( 'wp_head', 'wc_page_noindex' );
}
This question appears to be on three threads:
Solution 2:[2]
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' />
Solution 3:[3]
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
Solution 4:[4]
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'.
Solution 5:[5]
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
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Anthony |
Solution 3 | |
Solution 4 | Jazeb Pervez Butt |
Solution 5 | Dipankar |