ワードプレスでwp_get_archivesで月別一覧を表示したい

実現したいこと

wp_get_archivesで ('type' => 'monthly')として、
2023年5月や6月の一覧をarchive.phpに出したいです。

前提

archive.php に、<?php get_sidebar('AAA'); ?>で、AAA.phpを読み込み、
AAA.phpに、

<?php $args = array( 'type' => 'monthly', 'format' => 'custom', 'before' => '&nbsp;»&nbsp;', ); wp_get_archives($args); ?>

を記述しています。

サイドバーに
» 2023年6月
» 2023年5月
は、きちんと出力されるんですが、クリックしても、5月も6月も同じ表示がされ、
月別に分かれません。

archive.phpは、ニュースのページで常に5件表示できるように下記の記述にしています。

<section> <?php $args = array( 'post_type' =>'post', 'category_name' =>'info', 'posts_per_page' =>5 ); $the_query = new WP_query($args); if($the_query->have_posts()): while($the_query->have_posts()): $the_query->the_post(); ?> <a href="<?php the_permalink(); ?>"> <article class="section-1"> <div class="section-1-info-ph"> <?php the_post_thumbnail(); ?> </div> <div class="section-1-info-txt"> <p class="section-1-info-time"><?php the_time('Y年n月j日'); ?></p> <h2><?php the_title(); ?></h2> <p><?php the_content(); ?></p> </div> </article> </a> <?php endwhile; wp_reset_postdata(); endif; ?> </section>

発生している問題・エラーメッセージ

» 2023年6月
» 2023年5月
という表示はリンクもあり、出力されるんですが、クリックしても5月も6月も同じ表示がされ、
月別に分かれません。

アドレスは、
http://◎◎◎.local/2023/05/ 
http://◎◎◎.local/2023/06/ 
の様に月別にはなります。

該当のソースコード

<?php //AAA.php $args = array( 'type' => 'monthly', 'format' => 'custom', 'before' => '&nbsp;»&nbsp;', ); wp_get_archives($args); ?>

試したこと

ウィジェットを設置し、そこから

で、月別アーカイブを設置しても、

同じ現象が起こってしまいました。

補足情報(FW/ツールのバージョンなど)

archive.phpの記述が影響してるんでしょうか。
他の方法や、アドバイス頂けたら幸いです。よろしくお願いします。

コメントを投稿

0 コメント