2011-12-11 2 views
0

投稿を投稿者のサブアイテムとして一覧表示するにはどうすればよいですか?それは次のようになります:Wordpressで著者のサブアイテムとして投稿のリストを取得するにはどうすればいいですか?

私は$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); 

: My機能は、このようになりますか?

答えて

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(); 
関連する問題