From codex: is_author() is a conditional tag which determines whether the query is for an existing author archive page.
so it does not work for your scope.
Best solution, instead of using the template file header.php is to write a function in functions.php hooking the proper action wp_head
:
add_action('wp_head','AS_exclude_author_from_indexing');
function AS_exclude_author_from_indexing(){
$toIndex = array(111,112,113);
$user_id = get_the_author_meta( 'ID' );
if( !in_array($user_id,$toIndex)){
echo "<meta name=\"robots\" content=\"noindex,follow\">".PHP_EOL;
}
}
Related Posts:
- How do I get the author’s page url from their ID?
- Allow authors to post only in categories they create in WordPress
- Noindex subscriber author page
- How to hide the author box of a specific user?
- How to change the author box selection on a post to a custom taxonomy
- Show all people who commented on all posts by an author
- Show sidebar only to author of post
- How to have Function of a plugin using global vars into a shortcode?
- Assign new post author IF another user in custom field on post transition
- List of all theme customizer control types?
- Modify previous and next text from pagination links
- Shortcode putting html such as
- Calling a method from functions.php on a click of a button
- How to redirect users to custom lostpassword page?
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- Can I write ‘RewriteCond’ using ‘functions.php’?
- How do I create comment-reply-button using element not
- WordPress menu deletes when trying to add a hook
- Overriding a theme redux file in child theme
- Validate a users email address when using gmail to register
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- How to check If Oembed is empty or not
- Making Quote Plugin more efficient
- allow subscribers to see private posts without plug in
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- remove wp floating submenu in wp dashboard
- ACF: how do I get the fields and its values of a specific group?
- Fatal error: Uncaught Error: Call to undefined function test()
- Return a numerical function value in Customizer controls
- How can I get the values of my WordPress $wpdb query in Jquery?
- edit_comment_link is not showing for comment author
- Css loads very slow [closed]
- Show when user is online/offline in real time on user_profile.php
- Adding a widget function into the php theme file
- theme_root returning a truncated URI
- Call to undefined function get_userdata() in plugin
- Echo string and function?
- How to change menu labels
- how to test for all children (including multilevel grand-childern) of page
- Dilemma of Populating all the categories in a drop down list
- Add item to top of menu using a filter in functions.php
- Adding wrapper elements in the_date() like in the_title()?
- How to obtain the current website URL in my theme?
- Notify users only on post publish
- Plugin Generate Unexpected output during activation
- Remove Custom Divs from AMP pages
- Read array in php?
- Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
- PHP code for displaying WordPress posts in a static page not working
- How to get current post category details inside “loop”?
- Co-Authors Plus: How do I get all authors with a query?
- How to reference PHP in Javascript
- Only load certain artists on this page
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Get the alt text of the image in a array
- Make table disappear when fields are left blank?
- Woocommerce order status payment
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Unzip file in functions.php, and add it to cron
- Add Block Before Entry Title Using PHP
- How to assign page id with array in page_scheduled_event
- Dynamically populate parameter in Gravity Forms using PHP
- Store ajax data in PHP variable
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can i create a function tag in my plugin
- How to escape echo for input tag?
- Including user data in “new user notification email”
- Display current user metadata on WordPress page
- Reload page with a different shortcode when a user selects from a dropdown
- Refresh page after login with litespeed cache
- Return newly created category by code
- Woocommerce Add custom “Add to cart button” in single page with tags
- Hook into all password resets in WordPress and get password before hashing?
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- How to call a function from functions.php with ajax?
- remove_action() not working in page template – Genesis
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Dropdown menu on custom menu
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- WordPress get_post_meta issue
- Woocommerce Price Text
- Limit Taxonomy Parents
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Show custom default avatar instead of gravatar
- WordPress 2014 Theme – Featured Content with multiple tags?
- How to add button to top of theme customizer?
- ajax form function error
- Display custom meta box in my template file
- How to display the date under the post title?
- Simple Probléme in wordpress
- Options.php loop won’t show!
- Contact form with dynamic dropdown and filter
- Critical Error customiser
- Dynamic Email Handler with ‘header (“Location: …’
- WooCommerce: write featured image dimensions to custom fields in product’
- Generate and upload screenshot as featured image for user-submitted post
- transition_post_status hook, works – but not if the post is new
- Custom plugin doesn’t show in admin menu – when code added, displays an empty page