2

In wp-login.php default is:

<meta name="robots" content="noindex,follow">

I want to change it to:

<meta name="robots" content="noindex,nofollow">

Is there an easy way or script to change this?

  • 1
    Any reason you want to do that? – cybmeta Apr 15 '16 at 9:51
  • It's entirely possible that an external theme or plugin has injected unwanted links into the login page via actions or filters. @cybmeta – juz Apr 15 '16 at 11:01
  • What? Sorry but I don't understand what you mean with external theme, external plugin and unwanted links. Anyway, can you explain how adding noindex,nofollow robot meta tag can help with that and what benefits you get comparing with the default noindex, follow? If you have unwanted links, remove them. – cybmeta Apr 15 '16 at 13:02
  • My reason is some SEO requirements. – Jows Apr 16 '16 at 10:37
4

Extending @prosti answer, WordPress add it using action login_head in wp-login.php itself.

add_action( 'login_head', 'wp_no_robots' );

You can remove this action in theme/plugin and add your own action with custom callback function.

Example:-

//Keep priority 9 so we can remove WordPress action that is on 10
add_action( 'login_head', 'custom_no_robots', 9);
/**
 * Custom robot tags
 */
function custom_no_robots() {
    remove_action( 'login_head', 'wp_no_robots' );
    echo "<meta name='robots' content='noindex, nofollow' />\n";
}
  • 1
    I really like this remove_action. This is a great plus and smarter then possible filtering. – prosti Apr 16 '16 at 10:45
3

You can customize your WordPress login page with this action hook.

function f1() {
    echo '<meta name="robots" content="noindex,nofollow" >' . "\n";
}
add_action('login_head', 'f1');

The later one meta tag will prevail the original. PS. You can use filter if you plan to remove the original meta tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.