現在 wordpress サイトの改修を行っています。
投稿を年度別で表示できるようにしたいとのクライアントの要望で、そのように作ろうとしているんですが、どうもうまく動いてくれません。
参考にしたサイトは
WordPressで年度別アーカイブ一覧を表示
年度別(4月から始まる)アーカイブリストを表示する
などです。
上に上げた2つ目のサイトに記載のコードが動いた(ひとまず<my_get_archives_by_fiscal_year>で年度別リストの表示はできた)のですが、リスト上の年度をクリックしても、年度別ではなく年別アーカイブになってしまい、どうもうまくfunction.phpに書いた内容(4月始まり→3月終わり)が取得できていないようです。もしくは出力の仕方が間違っていると思われます。
出力(リストのリンク先)は、date.phpです。
こちらには特にクエリなど指定せず、ただのループにて出力しています。
date.phpは以下のような感じです。
php
1<ul class="catList cf"> 2<li class="catTitle">年度別に探す</li> 3<?php my_get_archives_by_fiscal_year(); ?></ul> 4</div> 5 6 7<?php 8 if(have_posts()) : 9 while (have_posts()) : the_post(); ?> 10 11 12<div class="news_contents clearfix"> 13 <p class="cap02"><?php the_field('event_date'); ?></p> 14 <p class="news_title2"><a href="<?php the_permalink(); ?>" target="_parent"><?php echo the_title();?></a></p> 15 <p><?php the_field('event_discription'); ?></p> 16 <p class="date"><?php the_time('Y年m月d日h時i分'); ?></p> 17 <p class="target"><?php if ( is_object_in_taxonomy( get_post_type(), 'category' ) ) : // Hide category text when not supported ?> 18<?php 19 /* translators: used between list items, there is a space after the comma */ 20 $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) ); 21 if ( $categories_list ): ?> 22<span class="noblue"> 23 <?php printf( __( '<span class="%1$s"></span> %2$s', 'twentyeleven' ), '', $categories_list ); 24 $show_sep = true; ?> 25</span> 26<?php endif; // End if categories ?> 27<?php endif; // End if is_object_in_taxonomy( get_post_type(), 'category' ) ?> 28</p> 29<br> 30<?php the_tags('<p class="tag nofloat"><span>','</span><span>','</span></p>');?> 31</div> 32<?php endwhile; endif; ?> 33 34
やったことあるよ!って方、また、わかるよ、という方にご助言いただけましたら幸いです。
よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。