wordpressで検索フォームから検索をかけると関連する記事を表示してくれるようにしました。
しかし、1ページめもそうですがページャーで2ページ目や3ページ目に飛ぶとレイアウトが崩れてしまいます。
レイアウトが崩れないようにするにはどうしたらいいでしょうか?
そして、下記のようなコードで検索し、表示させています。
テンプレートはtwentyseventeenを使っています。
「検索フォーム」
<form id="form" action="http://tokyo-times.jp" method="get"> <input id="s-box" name="s" type="text" placeholder="キーワードを入力"/> <button type="submit" id="s-btn-area"></button> </form>
「検索結果」
<h2 class="archive-title">「<?php echo esc_html($s); ?>」の検索結果</h2> <?php if (have_posts()) : 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(); ?>" title="<?php the_title_attribute(); ?>"><?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 --> </div> <?php endwhile; else : ?> <p>お探しの記事はありませんでした</p> <?php endif; ?> <?php if (have_posts() && function_exists("pagination")) { // 一覧ページネーション pagination($wp_query->max_num_pages); } ?>
wordpress初心者ゆえ、どこをどういじればいいのかもわからず、一応ブラウザの検証機能をみてみましたが原因がわかりませんでした。
こちらのページのように表示させたいです。
回答1件
あなたの回答
tips
プレビュー