質問編集履歴
3
single\.php に記述している所属しているカテゴリーを表示するコードも原因不明で出力がされていない為、その部分のコードも追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -249,3 +249,173 @@
|
|
249
249
|
|
250
250
|
|
251
251
|
不足している情報があれば是非教えて下さい。
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
追記------------------------------------
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
single.php に記述している所属しているカテゴリーを表示するコードも原因不明で出力がされていない状況でした。
|
262
|
+
|
263
|
+
ご参考になればと思い追記しました。
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
ここはマルっとUnderscoreのコードを流用しています。
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
```html
|
272
|
+
|
273
|
+
<p class="entry-category"><?php cseo_template_entry_footer(); ?></p>
|
274
|
+
|
275
|
+
↓
|
276
|
+
|
277
|
+
<p class="entry-category"></p>
|
278
|
+
|
279
|
+
```
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
```php
|
284
|
+
|
285
|
+
if ( ! function_exists( 'cseo_template_entry_footer' ) ) :
|
286
|
+
|
287
|
+
/**
|
288
|
+
|
289
|
+
* Prints HTML with meta information for the categories, tags and comments.
|
290
|
+
|
291
|
+
*/
|
292
|
+
|
293
|
+
function cseo_template_entry_footer() {
|
294
|
+
|
295
|
+
// Hide category and tag text for pages.
|
296
|
+
|
297
|
+
if ( 'post' === get_post_type() ) {
|
298
|
+
|
299
|
+
/* translators: used between list items, there is a space after the comma */
|
300
|
+
|
301
|
+
$categories_list = get_the_category_list( esc_html__( ', ', 'cseo_template' ) );
|
302
|
+
|
303
|
+
if ( $categories_list && cseo_template_categorized_blog() ) {
|
304
|
+
|
305
|
+
printf( '<span class="cat-links">' . esc_html__( '%1$s', 'cseo_template' ) . '</span>', $categories_list ); // WPCS: XSS OK.
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
/* translators: used between list items, there is a space after the comma */
|
312
|
+
|
313
|
+
// $tags_list = get_the_tag_list( '', esc_html__( ', ', 'cseo_template' ) );
|
314
|
+
|
315
|
+
// if ( $tags_list ) {
|
316
|
+
|
317
|
+
// printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'cseo_template' ) . '</span>', $tags_list ); // WPCS: XSS OK.
|
318
|
+
|
319
|
+
// }
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
326
|
+
|
327
|
+
echo '<span class="comments-link">';
|
328
|
+
|
329
|
+
/* translators: %s: post title */
|
330
|
+
|
331
|
+
comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'cseo_template' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) );
|
332
|
+
|
333
|
+
echo '</span>';
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
edit_post_link(
|
340
|
+
|
341
|
+
sprintf(
|
342
|
+
|
343
|
+
/* translators: %s: Name of current post */
|
344
|
+
|
345
|
+
esc_html__( 'Edit %s', 'cseo_template' ),
|
346
|
+
|
347
|
+
the_title( '<span class="screen-reader-text">"', '"</span>', false )
|
348
|
+
|
349
|
+
),
|
350
|
+
|
351
|
+
'<span class="edit-link">',
|
352
|
+
|
353
|
+
'</span>'
|
354
|
+
|
355
|
+
);
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
endif;
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
/**
|
364
|
+
|
365
|
+
* Returns true if a blog has more than 1 category.
|
366
|
+
|
367
|
+
*
|
368
|
+
|
369
|
+
* @return bool
|
370
|
+
|
371
|
+
*/
|
372
|
+
|
373
|
+
function cseo_template_categorized_blog() {
|
374
|
+
|
375
|
+
if ( false === ( $all_the_cool_cats = get_transient( 'cseo_template_categories' ) ) ) {
|
376
|
+
|
377
|
+
// Create an array of all the categories that are attached to posts.
|
378
|
+
|
379
|
+
$all_the_cool_cats = get_categories( array(
|
380
|
+
|
381
|
+
'fields' => 'ids',
|
382
|
+
|
383
|
+
'hide_empty' => 1,
|
384
|
+
|
385
|
+
// We only need to know if there is more than one category.
|
386
|
+
|
387
|
+
'number' => 2,
|
388
|
+
|
389
|
+
) );
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
// Count the number of categories that are attached to the posts.
|
394
|
+
|
395
|
+
$all_the_cool_cats = count( $all_the_cool_cats );
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
set_transient( 'cseo_template_categories', $all_the_cool_cats );
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
if ( $all_the_cool_cats > 1 ) {
|
406
|
+
|
407
|
+
// This blog has more than 1 category so cseo_template_categorized_blog should return true.
|
408
|
+
|
409
|
+
return true;
|
410
|
+
|
411
|
+
} else {
|
412
|
+
|
413
|
+
// This blog has only 1 category so cseo_template_categorized_blog should return false.
|
414
|
+
|
415
|
+
return false;
|
416
|
+
|
417
|
+
}
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
```
|
2
テスト環境と本番環境のディレクトリ構成に相違がありましたが統一させました。またURLにカテゴリースラッグが入っていなかったので修正記入させて頂きました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,13 +20,11 @@
|
|
20
20
|
|
21
21
|
・パーマリンクは「/%category%/%postname%」。
|
22
22
|
|
23
|
-
・「http://example.com/page/1/」と打ったら表示できるが2ページ目以降はダメ。
|
23
|
+
・「http://example.com/column/category-slug/page/1/」と打ったら表示できるが2ページ目以降はダメ。
|
24
24
|
|
25
25
|
・テスト環境だと問題ないが、本番環境だと本症状になる。
|
26
26
|
|
27
|
-
|
27
|
+
|
28
|
-
|
29
|
-
(テスト環境と本番環境の違いといえばディレクトリの違いくらいなのですが、他に調べる必要が有ることがあればご教授ください!)
|
30
28
|
|
31
29
|
|
32
30
|
|
1
例示用ドメインをexample\.comに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,11 +20,11 @@
|
|
20
20
|
|
21
21
|
・パーマリンクは「/%category%/%postname%」。
|
22
22
|
|
23
|
-
・「http://
|
23
|
+
・「http://example.com/page/1/」と打ったら表示できるが2ページ目以降はダメ。
|
24
24
|
|
25
25
|
・テスト環境だと問題ないが、本番環境だと本症状になる。
|
26
26
|
|
27
|
-
(テスト環境は、ルートにWPをインストール(
|
27
|
+
(テスト環境は、ルートにWPをインストール(example.com/)、本番は、下層ディレクトリにWPをインストール(example.com/column/)
|
28
28
|
|
29
29
|
(テスト環境と本番環境の違いといえばディレクトリの違いくらいなのですが、他に調べる必要が有ることがあればご教授ください!)
|
30
30
|
|