カスタム投稿ユーザー別記事表示
- 2013年04月18日
 - カスタム投稿
 
カスタム投稿設定で投稿記事をユーザー別に表示する設定です。
author.phpに以下の関数を設定、ループさせます。
<?php
$author_id = $post->post_author; // 現在の投稿者ID を変数に代入
$query= 'author=' . $author_id. '&showposts=20&post_type=blogpost'; // クエリを連結
query_posts($query); // クエリを実行
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Start: Post -->
<div>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p>
<span><?php the_time('Y年m月d日'); ?></span>
<span><?php the_author(); ?></span>
<span><?php the_category(", "); ?></span>
</p>
<div>
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
</div>
<div></div>
<?php if(has_tag()): ?><p><span><?php the_tags(""); ?></span></p><?php endif; ?>
<p><a href="<?php the_permalink(); ?>">続きを読む</a></p>
</div>
<!-- End: Post -->
<?php endwhile; endif; ?>



