2017-04-12 53 views
0

我試圖創建一個員工目錄來顯示所有WP用戶,然後允許您點擊並查看他們的配置文件,類似於標準的自定義帖子循環,然後查看單個用戶的配置文件, {customPost} .PHP。鏈接到wp用戶查詢中的用戶配置文件

下面是我爲我的用戶所建立的循環,但是iv爲循環創建了我的模板,但我正在努力如何輸出鏈接以點擊查看用戶配置文件?

<?php 

    // WP_User_Query arguments 
    $args = array(
     'order'   => 'ASC', 
     'orderby'  => 'id', 
    ); 

    // The User Query 
    $user_query = new WP_User_Query($args); 

    // The User Loop 
    if (! empty($user_query->results)) { 
     foreach ($user_query->results as $user) { ?> 
     <li><a href="">User Name</a> 
     </li> 

回答

0

這應該工作,

嘗試通過$ USER_ID全局變量充當以下,

<?php 
    global $user_ID; 
    if (get_the_author_meta('user_url',$user_ID)) : // If a user has filled out their decscription show a bio on their entries 
?> 
    <a class="meta-website" href="<?php the_author_meta('user_url',$user_ID); ?>">Author's Website</a>  
<?php endif; ?> 
+0

感謝您的回覆。我曾嘗試過,但沒有運氣。以下是我所擁有但沒有顯示的內容: '<?php $ users_id = $ user-> id; the_author_meta('user_url',$ users_id); ?>' – WillL

+0

您是否檢查過$ users_id是否有用戶ID? – Prabu

+0

是的iv嘗試其他元值,如first_name和user_email,它們正確顯示,但沒有任何url – WillL

0

由於@Prabu這個就解決了。以下爲我工作:

<?php echo get_author_posts_url($user->id); ?>"><?php the_author_meta('user_url', $user->id); ?></a> 

我當時跟單筆者頁面扔了404,但可以看到這是一個永久的問題得到一個問題。

+0

如果答案是正確的,你不應該作爲回答發佈,你只需點擊向上箭頭。 http://stackoverflow.com/help/accepted-answer – Prabu

相關問題