2016-07-02 34 views
-1

對於每篇博客文章,我需要顯示自定義meta guest_author,如果沒有設置,則默認用戶。WordPress的:如何獲得在WordPress的自定義元?

這就是我想用PHP做什麼,請幫助

如果guest_author可 回聲guest_author 其他 回聲筆者

+0

請更新您的問題與您的企圖。你的問題的邏輯是在第二個鏈接的最後答案。訪問此鏈接: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>