うさぎのイラスト

ネットアンサー55備忘録

web技術を書いていきます

カスタム投稿タイプの月別アーカイブ表示

-2015年05月26日-
<?php wp_get_archives('type=monthly&post_type=投稿名'); ?>
type=monthly 月別
post_type=投稿名
※post_typeに2つの投稿名を入れることはできないのかは別途調べるべき。
<?php
	$joken= array(
				'post_type' => array('post','daily','illustrator'),
				'posts_per_page' => 5,
				'paged' => $paged
				);

	if(is_month()){

		$setYear=get_the_date('Y');
		$setMonth=get_the_date('m');

		$joken['year']=$setYear;
		$joken['monthnum']=$setMonth;

	}


	query_posts($joken);
?>
post_typeは三種の投稿タイプを指定しています。
$jokenというArrayに現ページの「年」と「月」を格納させて、一覧表示をしています。