You cad add it via functions.php
with a hook, instead of inside the loop (you don’t really want to add a loop to header.php):
function add_author_meta() {
if (is_single()){
global $post;
$author = get_the_author_meta('user_nicename', $post->post_author);
echo "<meta name=\"author\" content=\"$author\">";
}
}
add_action( 'wp_enqueue_scripts', 'add_author_meta' );
Related Posts:
- Show content if parent page has children
- the_author_posts_link css class
- How do I get the author’s page url from their ID?
- Allow authors to post only in categories they create in WordPress
- Conditional statement for parent, child and grandchild pages
- Trying to use Ternary operators with WP Conditionals
- Missing Author Information
- When is is_admin() available?
- Check if current page is wp-admin
- Second Navigation inside header
- A Specific Blog post to be assigned as the landing page of my wordpress blog
- Get_the_author doesn’t return author name
- the_author() not working outside the loop
- Using is_page() in functions.php not working at all
- Output 2 items within the Loop
- conditional statement for custom taxonomy
- Can I change the contents of a description meta tag generated by Yoast?
- How to enqueue CSS and JS only on specific template?
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- How Can I Call Up The Author’s Name on a Post
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Retrieving Author ID in wp-admin area
- Storing Array from returned database query and using the array in a new query
- how could I load a different template part by page
- Getting the author name on author archive page
- A solution to set metatags with my page generating plugin?
- WordPress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs
- Getting error when trying to implement site-wide breadcrumbs in Twentytwentyone Theme [closed]
- Add meta noindex to post if it has a specific taxonomy
- How to remove role=”navigation” from all nav elements?
- WordPress, AJAX and pre_get_posts using conditional tags
- Change title only in dynamic page
- edit_comment_link is not showing for comment author
- If tag equals then show else show
- Remove author link wherever author’s name is display
- Category title output before opening title tag
- Conditional statement for dates
- How can I display a div ONLY if it is not a certain term page
- Don’t show certain div on front page?
- If ‘editor’ is empty, then
- Add class to DIV depending on page loaded
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- Noindex Posts From Certain Authors In WordPress
- Seo Friendly Filter URLs
- How to add no follow to specific links?
- WordPress yoast seo plugin – parse snippet var in meta description
- Undefined index for default custom theme option
- Remove conditional tag from header
- .html end of URl affected to SEO?
- Noindex subscriber author page
- Can’t change website Title on wordpress
- Display an image based on field value
- How to hide the author box of a specific user?
- Multidimensional Array
- Nginx WordPress and another Web app URL structure
- Genesis / custom template page / setting the page title and meta desc
- “if parent category is” conditional?
- Get All In One SEO Pack to use custom field instead of Content
- Conditional for Post Format
- Comment_author_url doing nothing
- conditional: if is page, and all subpages
- Woocommerce getting top level category parent and make all sub categories have the same template and menu
- page 1 is not paged
- Create a slug for a page in WordPress
- Create condition for Author bio Social Links
- Workaround for og:image unsupported webp image type, Yoast SEO?
- How to change the author box selection on a post to a custom taxonomy
- Obfuscate links (for SEO purpose) [closed]
- Custom URL for multiple categories hierarchy
- 404 on old link after changing post url
- Tag title not being returned in page title of tag archives
- Retrieve alt text by referencing the img src
- if user is admin display admin link and logout link else display logout only
- Redirect homepage /page/1/ to /blog/page/1/
- Add code only for blog posts
- How to define Og Meta Tags in header using conditions [duplicate]
- If Month=Particular month display content [closed]
- How to have Function of a plugin using global vars into a shortcode?
- Magento and WordPress URL integration [closed]
- How to echo a different field if another field is empty?
- Adding else if conditional statement to purchased theme
- When I use rewind_post() it shows menu items in my loop
- Conditional in foreach loop is outputting content twice
- Advanced custom fields Repeater conditional statement not working [closed]
- Load slideshow.css file only if Slideshow is checked / on
- Wrapping the_content() in Schema articleBody tag? [closed]
- Issues trying to add a href statment with PHP into a PHP Echo Statement [closed]
- Assign new post author IF another user in custom field on post transition
- Custom HTML/CSS Theme into WordPress – SEO considerations
- Create guest author page via php
- if is specific custom post in cpt
- seo meta description issue in google search
- advanced custom fields: repeater field within conditional statement [closed]
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- How to modify default tags in wp_head()
- How to make my scroll bar show under condition
- Side bar only if it’s not a single post or a specific page
- How to do SEO friendly filters urls?
- WooCommerce: Custom dropdown for variation selection
- How to Dynamically Change the author_base URL Slug by Language in WordPress?