For example, I have an url:
mysite.com/author/admin
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!
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 ) . '">';
}
}