For example, I have an url:


It's not considered as single post or single page to add meta tag via SEO plugin. And to this page I want to add something like:

<meta name="description" content="All posts by author admin."/>

Is there are any way to do this? Thanks in advance!

  • What i get from your question the stuff related to author archive. If you're using yoast seo, for example, you can check setting inside Archive->Author Archive – Ignat B. Aug 25 '16 at 9:46
  • Yeah, but from this menu I can't add meta tag to my url: /author/admin Maybe just hardcode it in header.php? – teheteh Aug 25 '16 at 10:17
  • Can you share how the page at this url is created? – bynicolas Aug 27 '16 at 1:23

There is not a standerized way to add HTML meta tags in WordPress but you can use wp_head action as a generic way to add meta tags.

I think description meta tag should not be in the theme, as you suggest in your answer, because description meta tag is a property of the document, nothing to do with the look and feel of the document, that is, the theme.

This is a samlple code to do it:

add_action( 'wp_head', 'cyb_author_archive_meta_desc' );
function cyb_author_archive_meta_desc() {

   // Check is we are in author archive
   // https://developer.wordpress.org/reference/functions/is_author/
   if( is_author() ) {
       // get_queried_object() returns current author in author's arvhives
       // https://developer.wordpress.org/reference/classes/wp_query/get_queried_object/
       $author = get_queried_object();

       // Generate meta description
       $description = sprintf( __( 'All posts by author %s', 'cyb-textdomain' ), $author->display_name );

       // Print description meta tag
       echo '<meta name="description" content="' . esc_attr( $description ) . '">';

| improve this answer | |

UPDT: Figured it out. Had to just hardcode it in header.php file located in my theme name folder.

<!-- Meta Tags -->

<?php if (is_archive() && !is_category()){
   echo '<meta property="og:description"  content="Your description"/>';
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.