2016-07-02 5 views
-1

ブログの投稿ごとに、デフォルトのユーザーに設定されていない場合は、カスタムのguest_authorを表示する必要があります。Wordpress:どのようにWordPressのカスタムメタを取得するには?

これは、私はPHPで何をしたいのか、

を助けてくださいされguest_authorが利用可能 エコーguest_author 他 エコー著者

+0

あなたの質問を更新してください。あなたの質問の論理は、2番目のリンクの最後の答えです。このリンクをご覧ください:1. [/ replace-author-url-with-guest-author-link](https://wordpress.org/support/topic/replace-author-url-with-guest-author-link)2 。[/how-to-handle-guest-authors-without-creating-profiles](https://wordpress.org/support/topic/how-to-handle-guest-authors-without-creating-profiles) – Bhavin

答えて

0

これは私の最終的なものですしました:

<span class="post-info-text"><?php echo 'This interview was taken by: </span> <span class="author-name vcard fn author" itemprop="name">'; ?> 
<?php $guest_author = get_post_meta(get_the_ID(), 'guest_author', true); 
if (!$guest_author){the_author_posts_link();}else{echo $guest_author;} ?></span> 
1

されている場合は、のようなものを使用することができます。

$userID = the_author_meta('ID'); 
if ($userID!= 0) //0 is for admin author id 
    { 
    get_the_author_meta('/*what ever you want to get */') 
    } 
else 
{ 
    //The else part for the default admin author. 
} 

リファレンス:https://codex.wordpress.org/Function_Reference/the_author_meta

関連する問題