admin管理员组

文章数量:1208155

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

本文标签: post metaCheck For getpostmeta on Author Archive Page