Archived topic
Add a specific on a speficif author's post.
7 replies · Started by supazena on August 6, 2018
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.
Hi,
Try your code in functions.php but has no effect on post loaded with single.php.
I also tried with ( is_author(authorID,'authorNickname')
Dont you think this link I found could help ?
https://wordpress.stackexchange.com/questions/188670/if-post-author-id-is-show-that
Ah, the author of the current single post. Try the updated code above: https://generatepress.com/forums/topic/add-a-specific-on-a-speficif-authors-post/#post-643452
Nice !
Thank you Tom !
Have a nice day :)
Greg
Thank you, you too! :)