2011-12-11 47 views
0

如何將帖子列爲作者的子項目?它應該看起來像:如何獲得作爲Wordpress作者子項目的帖子列表

<ul> 
    <li>Author</li> 
     <ul> 
      <li>Post1</li> 
      <li>Post2</li> 
     </ul> 
    </li> 
</ul> 

我有一個包含作者的數據,包括$author->ID的數組。這來自get_users()。 我的函數如下:

function add_custom_menu_items($items, $args) { 

    $authors = get_users('role=author'); \\Returns array of author meta-data. 

    return $items.$authors_str;  
} 
add_filter('wp_nav_menu_items', 'add_custom_menu_items', 5, 2); 

我在哪裏可以得到職位的名單?

回答

0

用戶wp query查詢職位,每個作者:

$the_query = new WP_Query('author=123'); 

$the_query = new WP_Query('author_name=rami'); 

和遍歷每個崗位,如:

// The Loop 
while ($the_query->have_posts()) : $the_query->the_post(); 
    echo '<li>'; 
    the_title(); 
    echo '</li>'; 
endwhile; 

// Reset Post Data 
wp_reset_postdata(); 
相關問題