Site logo

Archived topic

Add a specific on a speficif author's post.

7 replies · Started by supazena on August 6, 2018

Viewing posts 1–8 of 8

Hi,
I dont know if my topic's sentence is clear so here is my trouble :

I have to propose a generatepress blog to Google News but some content is republished content from 'originalAuthorName" so I have to add <meta name="Googlebot-News" content="noindex, nofollow"> for those post only.

My idea : create a virtual user called "originalAuthorName" and find a soluction to add this <meta> when this author is choosen.

1. Do you think it's the good/best way for my goal ?
2. Do you think it is possible ?

Greg
France

Hey Greg,

So you want WordPress to know when you add a post using a specific user, and to print a meta element when that's true?

Where would the meta element go?

Hi Tom,

Yes, When "userXYZ" (nickname or user id?) make a post then add <meta name=”Googlebot-News” content=”noindex, nofollow”> in the <head>

(goal : tell Google-News bot this autor doesn't offer unique content)

Don't know if it's possible.

You could try this function:

add_action( 'wp_head', function() {
    if ( is_single() ) {
        $post_author_id = get_post_field( 'post_author', get_the_ID() );

        if ( '10' == $post_author_id ) : ?>
            <meta name="Googlebot-News" content="noindex, nofollow">
        <?php endif;
    }
} );

10 being the ID of the author.

Nice !
Thank you Tom !

Have a nice day :)
Greg

Thank you, you too! :)

This archived topic is closed to new replies.