Check For get_post_meta on Author Archive Page

I've had a good look thru the Similar Questions for an answer and i'm looking to check if a value for a custom field key on single posts has been added using get_post_meta(); however i want to use this check on the author archive page.

This is my code in functions.php

global $wp_query;

$post = $wp_query-get_queried_object_id();

$meta  = get_post_meta( $post-ID, 'key', true );

if ( $meta ) :

Update : This function doesn't work on the author archive page.

function author_has_name() {
global $post;
$name = get_post_meta ($post-ID, 'author_name', true);
return !empty($name);
}

However, the code won't work in the author.php template

Topic user-meta author post-meta author-template Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.