Disallow author with robots.txt

I would like to disallow the authors (of posts for example) in the file robots.txt. In fact, I noticed that for some of my sites, Google indexed the authors of articles, which I don't want to. Someone thinks is it possible ?

(I tried something like Disallow: /author/ but I'm not sure it works...)

Thank you in advance,

ArbreMojo.

Topic robots.txt seo Wordpress google

Category Web


If you use Yoast SEO, you can go to Users > All Users, and in the Yoast SEO settings, check Do not allow search engines to show this author's archives in search results. See this link.

OR

With robots.txt, you can add:

User-agent: *
Disallow: /author/*

OR

You can also add the robots meta-tag to the appropriate pages:

function custom_function_filter_wp_robots( $robots ) {
    if(is_author()) {
        $robots['noindex'] = true;
    } 

    return $robots;
}

add_filter( 'wp_robots', 'custom_function_filter_wp_robots' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.