下記のサイトはwordpressで作ったサイトです。全て動的です。
トップページで右上の検索フォームから検索をかけると検索結果画面が表示されるのですが、
例えば、社会、エンタメ、アイドルなどのカテゴリーページに飛んでそこから検索フォームで検索をかけると結果が表示されません。
「この xxxxxxxx.jp ページが見つかりません」と出てきてしまいます。
トップページ以外でも検索結果を表示させる方法があったら教えて下さい。
ちなみにトップページと個別記事以外のページは固定ページで作られています。
「検索フォームページ」
<div style="display:inline-flex" > <form><input type="text" value="" name="s" class="s" placeholder="キーワードを入力"/><input type="submit" value="検索" alt="検索" title="検索" class="searchsubmit"></form><form role="search" method="get" id="searchform" action="http://xxxxxxxxx.jp/" ></form> </div>
「検索結果画面」
<h1>■検索結果</h1> <!-- newPostBox --> <div class="newPostBox"> <h2 class="archive-title">「<?php echo esc_html($s); ?>」の検索結果</h2> <?php if ( have_posts() ) : /* Start the Loop */ while ( have_posts() ) : the_post(); ?> <!-- imgTextBox --> <div class="imgTextBox"> <?php $category = get_the_category(); $cat_id = $category[0]->cat_ID; $cat_name = $category[0]->cat_name; $cat_slug = $category[0]->category_nicename; ?> <p class="textP"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br><span class="postDate"><?php echo get_the_date( $format, $post ); ?></span><span class="writeName"><?php the_author(); ?></span><span class="catName"><?php echo $cat_name; ?></span></p> <p class="imgP"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a></p> </div> <!-- imgTextBox --> <?php endwhile; // End of the loop. else : ?> <?php endif; ?> <div class="pagination"> <?php the_posts_pagination( array( 'mid_size' => 3, 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>', 'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>', ) ); ?> </div> <!-- newPostBox -->
「試したこと」
社会、エンタメ、アイドルなどのページで、そのカテゴリーページと同じカテゴリー名で検索するとそのカテゴリーの記事は一覧で表示される。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/11/06 14:31
退会済みユーザー
2018/11/06 14:34
2018/11/06 14:38
退会済みユーザー
2018/11/06 14:39
退会済みユーザー
2018/11/06 14:40
退会済みユーザー
2018/11/06 14:43