<?php $args = array( 'post_type' => 'タイプ名', 'taxonomy' => 'タクソノミー名', 'term' => 'ターム名', 'posts_per_page' => 10, 'numberposts' => '-1', ); $my_posts = get_posts($args); foreach ( $my_posts as $post ) { setup_postdata($post); ?> <li class="icon"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php } ?>
※posts_per_pageの数字は記事を何件表示するかの数字になります。
<?php wp_list_categories(array('taxonomy' => 'タクソノミー名')); ?>
<?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'タクソノミー名')); ?>
・記事の件数を表示する場合
<ul> <?php wp_list_categories(array('taxonomy' => 'architect','show_count' => 1)); ?> </ul>
<ul> <?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'info')); ?> </ul>
※info部分がカスタム分類名になります。
<?php $args = array( 'post_type' => 'カスタム投稿名', 'posts_per_page' => 10, 'numberposts' => '-1', ); $comments = get_comments($args); foreach($comments as $comment){ setup_postdata($post); ?> <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"> <?php comment_text() ?></a> <?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),' ','') ?> <?php } ?>
※posts_per_pageの数字は記事を何件表示するかの数字になります。
デフォルトではカスタム投稿の月別アーカイブ、年別アーカイブは出力できません。
出力するにはfunctions.phpに出力させるスクリプトを書くのですが、もっと簡単な方法はカスタム投稿のパーマリンクを設定するプラグイン「Custom Post Type Permalinks」を導入する事により下記の出力タグで表示できるようになります。
<h3>月別アーカイブ</h3> <ul> <?php wp_get_archives(array('post_type' => 'news', 'type' => 'monthly')); ?> </ul>
<h3>年別アーカイブ</h3> <ul> <?php wp_get_archives(array('post_type' => 'news', 'type' => 'yearly')); ?> </ul>
※post_type’ => ‘news’のnews部分がカスタム投稿タイプ名になります。