前提・実現したいこと
Wordpressサイトのカスタム投稿ページ(gallery)を作成しました。
サイドバーに月別のアーカイブリンクを設けましたが、
どのリンクをクリックしてもカスタム投稿ページの投稿が全て表示されてしまいます。
※月別の投稿のみに絞られない=gallery全件が表示されてしまう。
月別のア-カイブリンクをクリックした際は、
該当する投稿のみが表示されるようにしたいと思いますので、
wordpressの設定、phpの記述などで違っている部分がありましたら、
ご教授いただけますでしょうか?
■カスタム投稿名:gallery
発生している問題・エラーメッセージ
月別アーカイブページでカスタム投稿タイプの「gallery」全件が表示されてしまう。
該当のソースコード
■ファイル名:archive-gallery.php ▼ソースコード <main> <div id="single_left"> <div class="title_border"> <h2 class="gallery_title">事例集</h2> </div> <div id="news_list"> <?php query_posts('post_type=gallery'); ?> <?php if (have_posts()):while(have_posts()):the_post(); ?> <div class="news_cell linkwrap"> <div class="thumbimage"> <a href="<?php the_permalink() ?>"> <?php echo get_the_post_thumbnail( $tax_post->ID, array()); ?> </a> </div> <div class="news_info"> <a href="<?php the_permalink();?>"> <p><span class="date"><?php echo get_the_date('Y.m.d'); ?></span></p> <h3><?php the_title() ?></h3> <p><?php the_excerpt(); ?></p> </a> </div> </div> <?php endwhile; endif; ?> <?php wp_reset_postdata(); wp_reset_query(); ?> </div> </div> <?php get_sidebar('gallery'); ?> ーーーーーーーーーーーーーーーーーーーーーーーーー ■ファイル名:sidebar-gallery.php ▼ソースコード <h2 class="widgettitle">掲載年月</h2> <ul class="custom_post_menu"> <?php wp_get_archives('type=monthly&post_type=gallery'); ?> </ul>
試したこと
Custom Post Type UIで以下の設定にしています。
name: gallery
label: 事例集
singular_label: 事例集
description: 事例集のギャラリーページ
public: true
publicly_queryable: true
show_ui: true
show_in_nav_menus: true
show_in_rest: false
rest_base: ""
has_archive: true
has_archive_string: ""
exclude_from_search: false
capability_type: post
hierarchical: true
rewrite: true
rewrite_slug: ""
rewrite_withfront: true
query_var: true
query_var_slug: ""
menu_position: ""
show_in_menu: true
show_in_menu_string: ""
menu_icon: ""
custom_supports: ""
ーーーーーーーーーーーーーーーーーーーーーーーーーー
■Custom Post Type Permalinksで
galleryのパーマリンク設定を以下のようにしています。
サイトURL/カスタム投稿ページ/%year%/%monthnum%/%day%/%postname%/
has_archive: true / with_front: true
補足情報(FW/ツールのバージョンなど)
wordpressのバージョン: WordPress 4.8.5
導入プラグイン:
Custom Post Type UI
Custom Post Type Permalinks
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/04 03:01
2018/03/04 03:15
2018/03/04 09:32