質問編集履歴
4
重複してるwp_reset_postdata();を消去
test
CHANGED
File without changes
|
test
CHANGED
@@ -198,16 +198,14 @@
|
|
198
198
|
|
199
199
|
<?php endforeach; ?>
|
200
200
|
|
201
|
+
<?php else : //記事が無い場合 ?>
|
202
|
+
|
203
|
+
<li><p>記事はまだありません。</p></li>
|
204
|
+
|
205
|
+
<?php endif; ?>
|
206
|
+
|
201
207
|
<?php wp_reset_postdata(); ?>
|
202
208
|
|
203
|
-
<?php else : //記事が無い場合 ?>
|
204
|
-
|
205
|
-
<li><p>記事はまだありません。</p></li>
|
206
|
-
|
207
|
-
<?php endif; ?>
|
208
|
-
|
209
|
-
<?php wp_reset_postdata(); ?>
|
210
|
-
|
211
209
|
|
212
210
|
|
213
211
|
</div>
|
3
表示されるエラーを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -313,3 +313,31 @@
|
|
313
313
|
|
314
314
|
|
315
315
|
```
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
#### メインループに表示されるエラー
|
320
|
+
|
321
|
+
```
|
322
|
+
|
323
|
+
Notice: Undefined offset: 2 in /var/www/html/wp-includes/class-wp-query.php on line 3071
|
324
|
+
|
325
|
+
Call Stack
|
326
|
+
|
327
|
+
# Time Memory Function Location
|
328
|
+
|
329
|
+
1 0.0031 357416 {main}( ) .../index.php:0
|
330
|
+
|
331
|
+
2 0.0118 357704 require( '/var/www/html/wp-blog-header.php' ) .../index.php:17
|
332
|
+
|
333
|
+
3 1.3411 6177224 require_once( '/var/www/html/wp-includes/template-loader.php' ) .../wp-blog-header.php:19
|
334
|
+
|
335
|
+
4 1.3524 6182520 include( '/var/www/html/wp-content/themes/silhouette/index.php' ) .../template-loader.php:74
|
336
|
+
|
337
|
+
5 1.5265 6288368 the_post( ) .../index.php:26
|
338
|
+
|
339
|
+
6 1.5265 6288368 WP_Query->the_post( ) .../query.php:805
|
340
|
+
|
341
|
+
7 1.5265 6288368 WP_Query->next_post( ) .../class-wp-query.php:3099
|
342
|
+
|
343
|
+
```
|
2
ソースコードの成形
test
CHANGED
File without changes
|
test
CHANGED
@@ -148,186 +148,168 @@
|
|
148
148
|
|
149
149
|
<div class="m-firstView">
|
150
150
|
|
151
|
+
<div class="swiper-container m-firstView-swiper-container">
|
152
|
+
|
153
|
+
<div class="swiper-wrapper m-firstView-swiper-wrapper">
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
<?php
|
158
|
+
|
159
|
+
$args = array(
|
160
|
+
|
161
|
+
'numberposts' => 0, //表示(取得)する記事の数
|
162
|
+
|
163
|
+
'post_type' => 'top_image' //投稿タイプの指定
|
164
|
+
|
165
|
+
);
|
166
|
+
|
167
|
+
$posts = get_posts( $args );
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
if( $posts ) : foreach( $posts as $post) : setup_postdata( $post );
|
172
|
+
|
173
|
+
?>
|
174
|
+
|
151
|
-
<div class="m-firstView-
|
175
|
+
<div class="swiper-slide m-firstView-swiper-slide">
|
152
|
-
|
176
|
+
|
153
|
-
<h
|
177
|
+
<a href="" class="swiper-slide-link"></a>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
154
|
-
|
183
|
+
<?php
|
184
|
+
|
185
|
+
$image_id = get_post_thumbnail_id();
|
186
|
+
|
187
|
+
$image_url = wp_get_attachment_image_src($image_id, true);
|
188
|
+
|
189
|
+
?>
|
190
|
+
|
191
|
+
<div class="m-firstView-swiper-slide-image-outer" style="background-image: url(<?php echo $image_url[0]; ?>)">
|
192
|
+
|
193
|
+
<img src="<?php echo $image_url[0]; ?>" alt="" class="m-firstView-swiper-slide-image">
|
194
|
+
|
195
|
+
</div>
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
<?php endforeach; ?>
|
200
|
+
|
201
|
+
<?php wp_reset_postdata(); ?>
|
202
|
+
|
203
|
+
<?php else : //記事が無い場合 ?>
|
204
|
+
|
205
|
+
<li><p>記事はまだありません。</p></li>
|
206
|
+
|
207
|
+
<?php endif; ?>
|
208
|
+
|
209
|
+
<?php wp_reset_postdata(); ?>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
</div>
|
214
|
+
|
215
|
+
</div>
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
```
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
#### content.php
|
224
|
+
|
225
|
+
```php
|
226
|
+
|
227
|
+
<?php if (has_post_thumbnail( $post->ID ) ): ?>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<?php
|
232
|
+
|
233
|
+
// 記事のカテゴリー情報を取得する
|
234
|
+
|
235
|
+
// $cat = get_the_category();
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
// 取得した配列から必要な情報を変数に入れる
|
240
|
+
|
241
|
+
// $cat_name = $cat[0]->cat_name; // カテゴリー名
|
242
|
+
|
243
|
+
// $cat_slug = $cat[0]->category_nicename; // カテゴリースラッグ
|
244
|
+
|
245
|
+
?>
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
<?php
|
250
|
+
|
251
|
+
// 記事のタグ情報を取得する
|
252
|
+
|
253
|
+
$posttags = get_the_tags();
|
254
|
+
|
255
|
+
?>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
<artcile class="m-item-listItem-box <?php if ( $posttags ) { foreach ( $posttags as $tag ) { echo $tag->slug . ' ';} } ?>">
|
260
|
+
|
155
|
-
|
261
|
+
<i class="m-item-listItem-tag item-tag">
|
262
|
+
|
156
|
-
|
263
|
+
<?php
|
264
|
+
|
157
|
-
|
265
|
+
$homeurl = home_url();
|
266
|
+
|
158
|
-
|
267
|
+
if ($posttags) {
|
268
|
+
|
269
|
+
foreach($posttags as $tag) {
|
270
|
+
|
271
|
+
echo '<a href="' . $homeurl . '/archives/tag/' . $tag->slug . '" class="' . $tag->slug . '">' . $tag->name . '</a>';
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
?>
|
278
|
+
|
159
|
-
|
279
|
+
</i>
|
280
|
+
|
160
|
-
|
281
|
+
<div class="m-item-listItem-img-box">
|
282
|
+
|
161
|
-
|
283
|
+
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID) , 'max-control' ); ?>" alt="" class="m-item-listItem-img">
|
284
|
+
|
285
|
+
</div>
|
286
|
+
|
287
|
+
<?php endif; ?>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
<div class="m-item-listItem-text">
|
292
|
+
|
293
|
+
<h1 class="m-item-listItem-title">
|
294
|
+
|
295
|
+
<?php the_title(); ?>
|
162
296
|
|
163
297
|
</h1>
|
164
298
|
|
299
|
+
<p class="m-item-listItem-price">
|
300
|
+
|
301
|
+
¥<?php echo number_format(post_custom('価格'));?>
|
302
|
+
|
303
|
+
</p>
|
304
|
+
|
165
305
|
</div>
|
166
306
|
|
167
307
|
|
168
308
|
|
169
|
-
<div class="swiper-container m-firstView-swiper-container">
|
170
|
-
|
171
|
-
<div class="swiper-wrapper m-firstView-swiper-wrapper">
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
<?php
|
176
|
-
|
177
|
-
$args = array(
|
178
|
-
|
179
|
-
'numberposts' => 0, //表示(取得)する記事の数
|
180
|
-
|
181
|
-
'post_type' => 'top_image' //投稿タイプの指定
|
182
|
-
|
183
|
-
);
|
184
|
-
|
185
|
-
$posts = get_posts( $args );
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
if( $posts ) : foreach( $posts as $post) : setup_postdata( $post );
|
190
|
-
|
191
|
-
?>
|
192
|
-
|
193
|
-
<div class="swiper-slide m-firstView-swiper-slide">
|
194
|
-
|
195
|
-
|
309
|
+
<a href="<?php the_permalink(); ?>" class="m-item-listItem-link"></a>
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
310
|
+
|
202
|
-
|
203
|
-
$image_id = get_post_thumbnail_id();
|
204
|
-
|
205
|
-
$image_url = wp_get_attachment_image_src($image_id, true);
|
206
|
-
|
207
|
-
?>
|
208
|
-
|
209
|
-
<div class="m-firstView-swiper-slide-image-outer" style="background-image: url(<?php echo $image_url[0]; ?>)">
|
210
|
-
|
211
|
-
<img src="<?php echo $image_url[0]; ?>" alt="" class="m-firstView-swiper-slide-image">
|
212
|
-
|
213
|
-
|
311
|
+
</artcile>
|
214
|
-
|
215
|
-
|
312
|
+
|
216
|
-
|
217
|
-
|
313
|
+
|
218
|
-
|
219
|
-
<?php wp_reset_postdata(); ?>
|
220
|
-
|
221
|
-
<?php else : //記事が無い場合 ?>
|
222
|
-
|
223
|
-
<li><p>記事はまだありません。</p></li>
|
224
|
-
|
225
|
-
<?php endif; ?>
|
226
|
-
|
227
|
-
<?php wp_reset_postdata(); ?>
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
</div>
|
232
|
-
|
233
|
-
</div>
|
234
|
-
|
235
|
-
</div>
|
236
314
|
|
237
315
|
```
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
#### content.php
|
242
|
-
|
243
|
-
```php
|
244
|
-
|
245
|
-
<?php if (has_post_thumbnail( $post->ID ) ): ?>
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
<?php
|
250
|
-
|
251
|
-
// 記事のカテゴリー情報を取得する
|
252
|
-
|
253
|
-
// $cat = get_the_category();
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
// 取得した配列から必要な情報を変数に入れる
|
258
|
-
|
259
|
-
// $cat_name = $cat[0]->cat_name; // カテゴリー名
|
260
|
-
|
261
|
-
// $cat_slug = $cat[0]->category_nicename; // カテゴリースラッグ
|
262
|
-
|
263
|
-
?>
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
<?php
|
268
|
-
|
269
|
-
// 記事のタグ情報を取得する
|
270
|
-
|
271
|
-
$posttags = get_the_tags();
|
272
|
-
|
273
|
-
?>
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
<artcile class="m-item-listItem-box <?php if ( $posttags ) { foreach ( $posttags as $tag ) { echo $tag->slug . ' ';} } ?>">
|
278
|
-
|
279
|
-
<i class="m-item-listItem-tag item-tag">
|
280
|
-
|
281
|
-
<?php
|
282
|
-
|
283
|
-
$homeurl = home_url();
|
284
|
-
|
285
|
-
if ($posttags) {
|
286
|
-
|
287
|
-
foreach($posttags as $tag) {
|
288
|
-
|
289
|
-
echo '<a href="' . $homeurl . '/archives/tag/' . $tag->slug . '" class="' . $tag->slug . '">' . $tag->name . '</a>';
|
290
|
-
|
291
|
-
}
|
292
|
-
|
293
|
-
}
|
294
|
-
|
295
|
-
?>
|
296
|
-
|
297
|
-
</i>
|
298
|
-
|
299
|
-
<div class="m-item-listItem-img-box">
|
300
|
-
|
301
|
-
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID) , 'max-control' ); ?>" alt="" class="m-item-listItem-img">
|
302
|
-
|
303
|
-
</div>
|
304
|
-
|
305
|
-
<?php endif; ?>
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<div class="m-item-listItem-text">
|
310
|
-
|
311
|
-
<h1 class="m-item-listItem-title">
|
312
|
-
|
313
|
-
<?php the_title(); ?>
|
314
|
-
|
315
|
-
</h1>
|
316
|
-
|
317
|
-
<p class="m-item-listItem-price">
|
318
|
-
|
319
|
-
¥<?php echo number_format(post_custom('価格'));?>
|
320
|
-
|
321
|
-
</p>
|
322
|
-
|
323
|
-
</div>
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
<a href="<?php the_permalink(); ?>" class="m-item-listItem-link"></a>
|
328
|
-
|
329
|
-
</artcile>
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
```
|
1
タイトルの誤字を修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Word
|
1
|
+
Wordpressのindexページに複数のループを置きたい
|
test
CHANGED
File without changes
|