質問編集履歴

1

原因はわかったが解決方法が不明

2019/04/19 13:42

投稿

melot
melot

スコア13

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,17 @@
12
12
 
13
13
  ### 発生している問題・エラーメッセージ
14
14
 
15
+ パーマリンクを
16
+
17
+ ドメイン/カテゴリ/
18
+
15
- カテゴリの記事一覧をarchive.phpで作成しているのです、なぜかsingle.phpが読み込まれます
19
+ にするとカテゴリが個別投稿と認識されsingle.phpが読み込まれ
20
+
21
+
22
+
23
+ ドメイン/category/カテゴリ/
24
+
25
+ になると解消されるのですがどうしても/categry/を消したいです。
16
26
 
17
27
 
18
28
 
@@ -21,442 +31,6 @@
21
31
  ```ここに言語名を入力
22
32
 
23
33
 
24
-
25
- single.php
26
-
27
- <?php/*
28
-
29
- Template Name: single
30
-
31
- */
32
-
33
- ?>
34
-
35
- <!-- ヘッダー読み込み -->
36
-
37
- <?php get_header();?>
38
-
39
-
40
-
41
- <?php
42
-
43
- $cat = get_the_category(); // 情報取得
44
-
45
- $cat = $cat[0];
46
-
47
- $cat_name = $cat->cat_name; // カテゴリ名取得
48
-
49
- $cat_id = $cat->cat_ID; // カテゴリのリンクのみ取得
50
-
51
- ?>
52
-
53
-
54
-
55
- <div id="container" class="clearfix constBox topContainer">
56
-
57
- <div id="main">
58
-
59
- <!-- パンくずリスト-->
60
-
61
- <ul class="breadcrumb">
62
-
63
- <li><a href="***">ホーム</a> > </li>
64
-
65
- <li><a href="<?php echo esc_url(get_category_link($cat_id)); ?>">
66
-
67
- <?php echo $cat_name;?>の読み物
68
-
69
- </a> >
70
-
71
- </li>
72
-
73
- <!-- (' ')でulで出力されるのを防止 -->
74
-
75
- <li><?php the_title(); ?></li>
76
-
77
- </ul>
78
-
79
-
80
-
81
- <section id="article-contents">
82
-
83
- <?php
84
-
85
- if(have_posts()) :
86
-
87
- while(have_posts()) :
88
-
89
- the_post(); ?>
90
-
91
-
92
-
93
- <ul class="article-meta">
94
-
95
- <!-- 日時取得 -->
96
-
97
- <li class="article-date"><?php the_time('Y.n.j'); ?></li>
98
-
99
- <!-- カテゴリ、タグ取得 -->
100
-
101
- <li class="article-cat">
102
-
103
- <?php the_category(' ');?>
104
-
105
- <?php the_tags(' ');?>
106
-
107
- </li>
108
-
109
- </ul>
110
-
111
-
112
-
113
- <div class="firstview-box">
114
-
115
- <!-- アイキャッチ画像をフルサイズで表示(念のためCSSでも制御) -->
116
-
117
- <p><?php the_post_thumbnail('full'); ?></p>
118
-
119
- <!-- タイトル取得 -->
120
-
121
- <h1><?php the_title(); ?></h1>
122
-
123
- </div>
124
-
125
- <!-- 本文表示 -->
126
-
127
- <div id="article-body">
128
-
129
- <?php the_content(); ?>
130
-
131
- </div>
132
-
133
- <?php endwhile; else: ?>
134
-
135
- <p>
136
-
137
- <!-- 記事がない場合に表示させる文章があれば記述。 -->
138
-
139
- </p>
140
-
141
- <?php endif; ?>
142
-
143
-
144
-
145
- <div class="author-box">
146
-
147
- <div class="author-left">
148
-
149
- <!-- 投稿者のプロフィール画像を表示(サイズ300px) -->
150
-
151
- <?php echo get_avatar( get_the_author_id(), 300 ); ?>
152
-
153
- </div>
154
-
155
-
156
-
157
- <div class="author-right">
158
-
159
- <!-- 投稿者名を表示 -->
160
-
161
- <p class="author-name">■ <?php the_author(); ?></p>
162
-
163
-
164
-
165
- <!-- 投稿者のプロフィール情報を表示 -->
166
-
167
- <p class="author-prof"><?php the_author_meta('user_description'); ?></p>
168
-
169
- </div>
170
-
171
- </div>
172
-
173
- </section><!-- /#article-contents -->
174
-
175
-
176
-
177
- <!-- 前後記事と現在のページが属するカテゴリページへのリンク -->
178
-
179
- <div class="relation-wrappaer">
180
-
181
- <ul class="relation-article-move">
182
-
183
- <li>
184
-
185
- <?php if (get_previous_post()):?><!-- 前の記事があれば表示 -->
186
-
187
- <?php previous_post_link('%link','前の記事へ',TRUE,''); ?>
188
-
189
- <?php endif; ?>
190
-
191
- </li>
192
-
193
- <!-- 属するカテゴリリンク -->
194
-
195
- <li>
196
-
197
- <a href="<?php echo esc_url(get_category_link($cat_id)); ?>">
198
-
199
- 記事一覧へ
200
-
201
- </a>
202
-
203
- </li>
204
-
205
- <li>
206
-
207
- <?php if (get_next_post()):?><!-- 次の記事があれば -->
208
-
209
- <?php next_post_link('%link','次の記事へ',TRUE,''); ?>
210
-
211
- <?php endif; ?>
212
-
213
- </li>
214
-
215
- </ul>
216
-
217
- </div>
218
-
219
- <p class="cat-name"><?php echo $cat_name;?>の読み物
220
-
221
- <span> <!-- 属するカテゴリリンク -->
222
-
223
- <a href="<?php echo esc_url(get_category_link($cat_id)); ?>">
224
-
225
- 一覧を見る
226
-
227
- </a>
228
-
229
- </span>
230
-
231
- </p>
232
-
233
- <!-- 関連記事一覧 -->
234
-
235
- <section class="article-list">
236
-
237
- <?php
238
-
239
- // 同じカテゴリから記事を6件呼び出す
240
-
241
- $categories = get_the_category($post->ID);
242
-
243
- $category_ID = array();
244
-
245
-
246
-
247
- foreach($categories as $category):
248
-
249
- array_push( $category_ID, $category -> cat_ID);
250
-
251
- endforeach ;
252
-
253
-
254
-
255
- $args = array(
256
-
257
- 'post__not_in' => array($post -> ID), // 今読んでいる記事を除く
258
-
259
- 'posts_per_page'=> 6,
260
-
261
- 'category__in' => $category_ID,
262
-
263
- 'orderby' => 'date', // 日付順に並び替え
264
-
265
- );
266
-
267
-
268
-
269
- $query = new WP_Query($args);
270
-
271
- if( $query -> have_posts() ): while ($query -> have_posts()) : $query -> the_post();
272
-
273
- ?>
274
-
275
- <div class="relation-ariicle">
276
-
277
- <a href="<?php the_permalink(); ?>">
278
-
279
- <div class="relation-img">
280
-
281
- <?php the_post_thumbnail('full'); ?>
282
-
283
- </div>
284
-
285
- <p class="relation-title"><?php the_title(); ?></p>
286
-
287
- <p class="relation-meta">
288
-
289
- <span class="relation-date"><?php the_time('Y.n.j'); ?></span>
290
-
291
- <span class="relation-cat"><?php the_category(' ');?></span>
292
-
293
- </p>
294
-
295
- </a>
296
-
297
- </div>
298
-
299
- <?php endwhile; endif; ?>
300
-
301
- <?php wp_reset_postdata(); ?>
302
-
303
- </section>
304
-
305
- </div><!-- /#main -->
306
-
307
- <?php get_sidebar(); ?><!-- サイドバー読み込み -->
308
-
309
- </div><!-- /#container -->
310
-
311
-
312
-
313
- <!-- フッター読み込み -->
314
-
315
- <?php get_footer(); ?>
316
-
317
-
318
-
319
- -----------------------------------------------------------------------------------------
320
-
321
- archive.php
322
-
323
- <?php/*
324
-
325
- Template Name: arcive
326
-
327
- */
328
-
329
- ?>
330
-
331
-
332
-
333
- <?php get_header();?>
334
-
335
- <div id="container" class="clearfix constBox topContainer">
336
-
337
- <div id="main">
338
-
339
- <!-- パンくずリスト-->
340
-
341
- <ul class="breadcrumb">
342
-
343
- <li><a href="***">ホーム></a></li>
344
-
345
- <?php $postcate = get_the_category(); ?>
346
-
347
- <li><?php echo get_category_parents($postcate[0]->term_id,TRUE,''); ?></li>
348
-
349
- </ul>
350
-
351
- <!-- カテゴリ見出し 画像は保留-->
352
-
353
- <div class="archive-main">
354
-
355
- <h2 class="cat-title"><?php the_archive_title('','の読み物');?></h2>
356
-
357
- <p class="cat-description"><?php echo category_description();?></p>
358
-
359
- </div>
360
-
361
-
362
-
363
- <!-- カテゴリ一覧 -->
364
-
365
- <ul class="cat-list">
366
-
367
- <?php wp_list_categories('title_li=&use_desc_for_title=0'); ?>
368
-
369
- </ul>
370
-
371
-
372
-
373
-
374
-
375
- <!-- 関連記事一覧 -->
376
-
377
- <section class="article-list">
378
-
379
- <?php
380
-
381
- // 同じカテゴリから記事を12件呼び出す
382
-
383
- $categories = get_the_category($post->ID);
384
-
385
- $category_ID = array();
386
-
387
-
388
-
389
- foreach($categories as $category):
390
-
391
- array_push( $category_ID, $category -> cat_ID);
392
-
393
- endforeach ;
394
-
395
-
396
-
397
- $args = array(
398
-
399
- 'posts_per_page'=> 12,
400
-
401
- 'category__in' => $category_ID,
402
-
403
- 'orderby' => 'date', // 日付順に並び替え
404
-
405
- );
406
-
407
-
408
-
409
- $query = new WP_Query($args);
410
-
411
- if( $query -> have_posts() ): while ($query -> have_posts()) : $query -> the_post();
412
-
413
- ?>
414
-
415
- <div class="relation-ariicle">
416
-
417
- <a href="<?php the_permalink(); ?>">
418
-
419
- <div class="relation-img">
420
-
421
- <?php the_post_thumbnail('full'); ?>
422
-
423
- </div>
424
-
425
- <p class="relation-title"><?php the_title(); ?></p>
426
-
427
- <p class="relation-meta">
428
-
429
- <span class="relation-date"><?php the_time('Y.n.j'); ?></span>
430
-
431
- <span class="relation-cat"><?php the_category(' ');?></span>
432
-
433
- </p>
434
-
435
- </a>
436
-
437
- </div>
438
-
439
- <?php endwhile; endif; ?>
440
-
441
- <?php wp_reset_postdata(); ?>
442
-
443
- </section>
444
-
445
- </div><!-- main -->
446
-
447
- <!-- サイドバー読み込み -->
448
-
449
- <?php get_sidebar(); ?>
450
-
451
- </div> <!-- container -->
452
-
453
-
454
-
455
-
456
-
457
- <!-- フッター読み込み -->
458
-
459
- <?php get_footer();?>
460
34
 
461
35
  ```
462
36