Skip to content

Instantly share code, notes, and snippets.

@tkc49
Last active December 14, 2015 10:48
Show Gist options
  • Save tkc49/5074987 to your computer and use it in GitHub Desktop.
Save tkc49/5074987 to your computer and use it in GitHub Desktop.
[WordPress] Display a list of articles for each author. /著作者ごとに記事を一覧表示
<?php $users = get_users(); ?>
<ul>
<?php foreach($users as $user): ?>
<li><?php echo $user->display_name; ?></li>
<ul>
<?php $posts = get_posts("author=$user->ID&orderby=date&post_type=post&posts_per_page=5"); ?>
<?php foreach( $posts as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
</ul>
<?php endforeach; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment