質問編集履歴

2

誤字修正

2018/11/02 09:24

投稿

ryamaguchi
ryamaguchi

スコア7

test CHANGED
File without changes
test CHANGED
@@ -82,7 +82,7 @@
82
82
 
83
83
 
84
84
 
85
- marlboro_taraさんからご指摘がありました。ありがとうございます。
85
+ marlboro_tataさんからご指摘がありました。ありがとうございます。
86
86
 
87
87
  search.phpの内容を転記いたします。
88
88
 

1

関係ファイル(search.php)の内容転記

2018/11/02 09:24

投稿

ryamaguchi
ryamaguchi

スコア7

test CHANGED
File without changes
test CHANGED
@@ -58,7 +58,7 @@
58
58
 
59
59
 
60
60
 
61
- ###補足情報(言語/FW/ツール等のバージョンなど)
61
+ ###補足情報1(言語/FW/ツール等のバージョンなど)
62
62
 
63
63
 
64
64
 
@@ -75,3 +75,185 @@
75
75
  Apache/2.4.33
76
76
 
77
77
  WordPressバージョン:4.9.8
78
+
79
+
80
+
81
+ ###補足情報2(search.phpの内容)
82
+
83
+
84
+
85
+ marlboro_taraさんからご指摘がありました。ありがとうございます。
86
+
87
+ search.phpの内容を転記いたします。
88
+
89
+
90
+
91
+ ```
92
+
93
+ <?php
94
+
95
+ /**
96
+
97
+ * The template for displaying search results pages
98
+
99
+ *
100
+
101
+ * @package WordPress
102
+
103
+ * @subpackage Twenty_Sixteen
104
+
105
+ * @since Twenty Sixteen 1.0
106
+
107
+ */
108
+
109
+
110
+
111
+ get_header(); ?>
112
+
113
+
114
+
115
+ <!--<section id="primary" class="content-area">
116
+
117
+ <main id="main" class="site-main" role="main">-->
118
+
119
+ <section>
120
+
121
+ <?php
122
+
123
+ if ( empty( get_search_query() ) ) {
124
+
125
+ // 検索キーワードがないとき
126
+
127
+ echo '<p>検索キーワードが未入力です。</p>';
128
+
129
+ }else{
130
+
131
+ ?>
132
+
133
+ <?php if ( have_posts() ) {
134
+
135
+ $max_num_pages = $wp_query->max_num_pages;
136
+
137
+ ?>
138
+
139
+
140
+
141
+ <!--
142
+
143
+ <header class="page-header">
144
+
145
+ <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentysixteen' ), '<span>' . esc_html( get_search_query() ) . '</span>' ); ?></h1>
146
+
147
+ </header>-->
148
+
149
+ <!-- .page-header -->
150
+
151
+ <p><?php printf( __( 'キーワード「%s」の検索結果です', 'twentysixteen' ), '<span>' . esc_html( get_search_query() ) . '</span>' ); ?></p>
152
+
153
+ <ul class="text-list">
154
+
155
+ <?php
156
+
157
+ // Start the loop.
158
+
159
+ while ( have_posts() ) :the_post();
160
+
161
+ echo '<li>';
162
+
163
+ echo '<a href="';
164
+
165
+ the_permalink();
166
+
167
+ echo '">';
168
+
169
+ echo '<h3>';
170
+
171
+ the_title();
172
+
173
+ echo '</h3>';
174
+
175
+ echo '<p>';
176
+
177
+ the_excerpt();
178
+
179
+ echo '</p>';
180
+
181
+ echo '</a></li>';
182
+
183
+
184
+
185
+ /**
186
+
187
+ * Run the loop for the search to output the results.
188
+
189
+ * If you want to overload this in a child theme then include a file
190
+
191
+ * called content-search.php and that will be used instead.
192
+
193
+ */
194
+
195
+ //get_template_part( 'template-parts/content', 'search' );
196
+
197
+
198
+
199
+ // End the loop.
200
+
201
+ endwhile;
202
+
203
+ echo '</ul>';
204
+
205
+ // Previous/next page navigation.
206
+
207
+ /*
208
+
209
+ the_posts_pagination(
210
+
211
+ array(
212
+
213
+ 'prev_text' => __( 'Previous page', 'twentysixteen' ),
214
+
215
+ 'next_text' => __( 'Next page', 'twentysixteen' ),
216
+
217
+ 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
218
+
219
+ )
220
+
221
+ );
222
+
223
+ */
224
+
225
+ if (function_exists("pagination"))
226
+
227
+ {
228
+
229
+ pagination(3, $max_num_pages);
230
+
231
+ }
232
+
233
+
234
+
235
+ // If no content, include the "No posts found" template.
236
+
237
+ }else{
238
+
239
+ //get_template_part( 'template-parts/content', 'none' );
240
+
241
+ //echo '<p>記事がありません。</p>';
242
+
243
+ echo '<p>'.'キーワード「<span>'.esc_html(get_search_query()).'</span>」に該当するページはありません。</p>';
244
+
245
+ }
246
+
247
+ }
248
+
249
+ ?>
250
+
251
+ <!--</main>--><!-- .site-main -->
252
+
253
+ </section><!-- .content-area -->
254
+
255
+
256
+
257
+ <?php get_footer(); ?>
258
+
259
+ ```