Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul>
- <?php
- //URLパラメータ取得
- $yget = isset($_GET['y']) ? htmlspecialchars($_GET['y']) : null;
- //年度別アーカイブリスト
- $archives_year = strip_tags(wp_get_archives('type=monthly&show_count=0&format=custom&echo=0'));
- $archives_year = split("\n",$archives_year);
- $archives_year = preg_replace("/(\d{4})年1月/ue","'\\1'-1",$archives_year);
- $archives_year = preg_replace("/(\d{4})年2月/ue","'\\1'-1",$archives_year);
- $archives_year = preg_replace("/(\d{4})年3月/ue","'\\1'-1",$archives_year);
- $archives_year = preg_replace("/年\d{1,2}月/","",$archives_year);
- $archives_year = array_filter($archives_year);
- $archives_year = array_unique($archives_year);
- $archives_year = array_values($archives_year);
- if(empty($yget)){
- foreach($archives_year as $year_value){
- echo '<li><a href="'.home_url('/').'history/?y='.$year_value.'">'.$year_value.'年度</a></li>';
- }
- }
- ?>
- </ul>
- <?php //記事一覧
- if(!empty($yget)){ ?>
- <h2><?php echo $yget; ?>年度の記事一覧</h2>
- <dl>
- <?php
- $paged = get_query_var('paged') ? get_query_var('paged') : 1;
- $start = $yget.'/4/1';
- $end = ($yget+1).'/3/31 23:59:59';
- $args = array(
- 'post_type' => 'post',
- 'posts_per_page' => 10,
- 'paged' => $paged,
- 'date_query' => array(
- 'after' => $start,
- 'before' => $end,
- ),
- );
- $the_query = new WP_Query( $args );
- if ( $the_query->have_posts() ) :
- while ( $the_query->have_posts() ) : $the_query->the_post();
- $date = get_the_date('Y-m-d');
- ?>
- <dd><?php the_title(); ?>(<?php echo $date; ?>)</dd>
- <?php
- endwhile;
- endif;
- ?>
- </dl>
- <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(array('query' => $the_query)); } ?>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement