タグ一覧ページが必要で、固定ページにタグを導入しました。
しかしタグ一覧ページのみウィジットで作ったサイドバーが表示されません。
archive.phpが割り当てられているぺーじです。
同じget_sidebar();で他のページもサイドバーが問題なく挿入されているのですが
どこで何が違って、どのようにしたらサイドバーが表示できますでしょうか?
ご教授いただけると幸いです。
問題のリンク
http://〇〇〇〇〇.jp/test/tag/heart/
<section id="nav_menu-2" class="widget widget_nav_menu">「この中に入るはずのメニューが入らない」</section> ```<div class="menu-service-container"><ul id="menu-service" class="menu"><li id="menu-item....と続くはずなんですが ```ここに言語を入力 archive.php <?php get_header(); ?> <section id="primary" class="content-area col-sm-12 col-lg-8"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : ?> <header class="page-header"> <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_description( '<div class="archive-description">', '</div>' ); ?> </header><!-- .page-header --> <?php /* Start the Loop */ while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', get_post_format() ); endwhile; the_posts_navigation(); else : get_template_part( 'template-parts/content', 'none' ); endif; ?> </main><!-- #main --> </section><!-- #primary --> <?php get_sidebar(); get_footer();
template-parts/content.php <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-thumbnail"> <?php the_post_thumbnail(); ?> </div> <header class="entry-header"> <?php if ( is_single() ) : the_title( '<h1 class="entry-title">', '</h1>' ); else : the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); endif; if ( 'post' === get_post_type() ) : ?> <div class="entry-meta"> <time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('Y.m.d'); ?></time> <p><?php the_category(', '); ?></p> </div><!-- .entry-meta --> <?php endif; ?> </header><!-- .entry-header --> <div class="entry-content"> <?php if ( is_single() ) : the_excerpt(); else : the_excerpt( __( 'Continue reading <span class="meta-nav">→</span>', 'wp-bootstrap-starter' ) ); endif; wp_link_pages( array( 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'wp-bootstrap-starter' ), 'after' => '</div>', ) ); ?> </div><!-- .entry-content --> </article><!-- #post-## -->
functions.php function wp_bootstrap_starter_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', 'wp-bootstrap-starter' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', 'wp-bootstrap-starter' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) );
追記
テーマはこちらのテーマをカスタマイズしています。
https://afterimagedesigns.com/wp-bootstrap-starter/
追記
ナビゲーションが全て表示されない事がわかりました。
もう一つグローバルナビがあるのですが、このページに限り表示されません。
get_sidebar()問題ないはずなんですが・・・
後から気がついたのですが、カスタムメニューで作ったメニューがarchive.phpだけで表示されない
get_sidebar();はついております。
htmlで確認するとメニューのタグの部分がそっくりそのまま抜けていでおそらくPHP側で問題があるようです。
メニューを表示するにはどうしたらいいでしょうか?
固定ページに以下のようにタグ機能をつけました。
functions.php // 固定ページにカテゴリーを設定 function add_categorie_to_pages(){ register_taxonomy_for_object_type('category', 'page'); } add_action('init','add_categorie_to_pages'); // カテゴリーアーカイブに固定ページを含める function add_page_to_category_archive( $query ) { if ( $query->is_category== true && $query->is_main_query() ) { $query->set('post_type', array( 'post', 'page' )); } } add_action( 'pre_get_posts', 'add_page_to_category_archive' ); // 固定ページにタグを設定 function add_tag_to_page() { register_taxonomy_for_object_type('post_tag', 'page'); } add_action('init', 'add_tag_to_page'); // タグアーカイブに固定ページを含める function add_page_to_tag_archive( $obj ) { if ( is_tag() ) { $obj->query_vars['post_type'] = array( 'post', 'page' ); } } add_action( 'pre_get_posts', 'add_page_to_tag_archive' );
回答2件
あなたの回答
tips
プレビュー