2013-03-18 13 views
0

我創建了我自己的author.php模板。我想顯示作者的自定義元字段代碼示例是在此圖像中:http://prntscr.com/wsdsa在author.php中顯示作者meta的錯誤

但WordPress的不顯示任何東西?我該怎麼辦 ?

   <div class="BCol"> 
        <?php echo keepAuthorImage(); ?> 
       </div> 
       <div class="ACol"> 
        <div class="A1"><?php echo get_the_author_meta('first_name') ?> <?php echo get_the_author_meta('last_name') ?></div> 
        <div class="A2"><?php echo the_author_meta('job') ?></div> 
        <div class="A3"><?php echo get_the_author_meta('location') ?></div> 
        <div class="A5"> 
         <a href="<?php echo get_the_author_meta('userwebpages') ?>" target="_blank"><img src="<?php echo THEME; ?>/_assets/_img/websiteicon.png" alt=""></a> 
         <a href="http://twitter.com/<?php echo get_the_author_meta('twitter') ?>" target="_blank"><img src="<?php echo THEME; ?>/_assets/_img/twitteric.png" alt=""></a> 
         <a href="http://instagram.com/<?php echo get_the_author_meta('instagram') ?>" target="_blank"><img src="<?php echo THEME; ?>/_assets/_img/instagramic.png" alt=""></a> 
        </div> 
        <div class="A4"><?php echo get_the_author_meta('aboute') ?></div> 
       </div> 

有幫助嗎?謝謝。

回答

1

WordPress有預先定義的變量,如

$貓

$標籤

等 你必須使用

$筆者

,使您的過程。

+0

Thaks DINC。這樣可行。 – 2013-03-18 09:25:38

0

你在做什麼錯誤的是你沒有在循環中使用你的get_the_author_meta()函數,所以你需要指定作者ID。

要麼使用功能方面的循環,或使用簡單,下面的代碼

<?php 
global $current_user; 
$current_user = wp_get_current_user(); 
$uid=$current_user->ID; 
?> 

改變你的函數筆者元作爲

<?php echo get_the_author_meta('first_name',$uid) ?> 

您所有的作者元以獲得更多幫助,您可以檢查參考代碼http://codex.wordpress.org/Function_Reference/get_the_author_meta

+0

非常感謝你,但我有很多作者,在我的項目上我想在author.php上顯示他們的個人資料數據?其實我真的不需要當前的用戶ID,我只需要在查看時得到Author id?author = 1(例如) – 2013-03-18 08:17:24