質問編集履歴
4
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -51,7 +51,7 @@
|
|
51
51
|
//店舗
|
52
52
|
register_taxonomy(
|
53
53
|
'store',
|
54
|
-
'
|
54
|
+
'location',
|
55
55
|
array(
|
56
56
|
'label' => '店舗',
|
57
57
|
'singular_label' => '店舗',
|
3
不足を指摘された内容を追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,8 +14,80 @@
|
|
14
14
|
```
|
15
15
|
|
16
16
|
### 該当のソースコード
|
17
|
+
function.php
|
18
|
+
```
|
19
|
+
add_action( 'init', 'create_post_type' );
|
20
|
+
function create_post_type() {
|
21
|
+
register_post_type( 'location', [ // 投稿タイプ名の定義
|
22
|
+
'labels' => [
|
23
|
+
'name' => '店舗ブログ', // 管理画面上で表示する投稿タイプ名
|
24
|
+
'singular_name' => 'location', // カスタム投稿の識別名
|
25
|
+
],
|
26
|
+
'public' => true, // 投稿タイプをpublicにするか
|
27
|
+
'has_archive' => true, // アーカイブ機能ON/OFF
|
28
|
+
'menu_position' => 5, // 管理画面上での配置場所
|
29
|
+
'supports' => array(
|
30
|
+
'title',
|
31
|
+
'editor',
|
32
|
+
'thumbnail',
|
33
|
+
'revisions',
|
34
|
+
'excerpt',
|
35
|
+
'custom-fields',
|
36
|
+
),
|
37
|
+
'rewrite' => array('slug' => 'location', 'with_front' => false),
|
38
|
+
'show_in_rest' => true, // 5系から出てきた新エディタ「Gutenberg」を有効にする
|
39
|
+
]);
|
40
|
+
//カテゴリを投稿と共通設定にする
|
41
|
+
// register_taxonomy_for_object_type('info-cat', 'infopage');
|
42
|
+
// //タグを投稿と共通設定にする
|
43
|
+
// register_taxonomy_for_object_type('post_tag', 'infopage');
|
44
|
+
}
|
17
45
|
|
18
|
-
|
46
|
+
//
|
47
|
+
// カスタム分類(カスタムタクソノミー)
|
48
|
+
//
|
49
|
+
|
50
|
+
function add_taxonomy() {
|
51
|
+
//店舗
|
52
|
+
register_taxonomy(
|
53
|
+
'store',
|
54
|
+
'location_blog',
|
55
|
+
array(
|
56
|
+
'label' => '店舗',
|
57
|
+
'singular_label' => '店舗',
|
58
|
+
'labels' => array(
|
59
|
+
'all_items' => '店舗一覧',
|
60
|
+
'add_new_item' => '店舗を追加'
|
61
|
+
),
|
62
|
+
'public' => true,
|
63
|
+
'show_ui' => true,
|
64
|
+
'show_in_nav_menus' => true,
|
65
|
+
'hierarchical' => true
|
66
|
+
)
|
67
|
+
);
|
68
|
+
//カテゴリー
|
69
|
+
register_taxonomy(
|
70
|
+
'location_cat',
|
71
|
+
'location',
|
72
|
+
array(
|
73
|
+
'label' => 'カテゴリー',
|
74
|
+
'singular_label' => 'カテゴリー',
|
75
|
+
'labels' => array(
|
76
|
+
'all_items' => 'カテゴリー一覧',
|
77
|
+
'add_new_item' => 'カテゴリーを追加'
|
78
|
+
),
|
79
|
+
'public' => true,
|
80
|
+
'show_ui' => true,
|
81
|
+
'show_in_nav_menus' => true,
|
82
|
+
'hierarchical' => true
|
83
|
+
)
|
84
|
+
);
|
85
|
+
|
86
|
+
}
|
87
|
+
add_action( 'init', 'add_taxonomy' );
|
88
|
+
```
|
89
|
+
header.php
|
90
|
+
```
|
19
91
|
<?php if (get_post_type() === 'location' && is_single('')): ?>
|
20
92
|
「特定のHTMLソース」
|
21
93
|
<?php endif; ?>
|
2
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
### 該当のソースコード
|
17
17
|
|
18
18
|
```ここに言語名を入力
|
19
|
-
<?php if (get_post_type() === '
|
19
|
+
<?php if (get_post_type() === 'location' && is_single('')): ?>
|
20
20
|
「特定のHTMLソース」
|
21
21
|
<?php endif; ?>
|
22
22
|
```
|
1
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,12 +19,11 @@
|
|
19
19
|
<?php if (get_post_type() === 'location_blog' && is_single('')): ?>
|
20
20
|
「特定のHTMLソース」
|
21
21
|
<?php endif; ?>
|
22
|
-
|
22
|
+
```
|
23
23
|
これで詳細ページ全てに表示できるのはわかったのですが、
|
24
24
|
個別の店舗ごとにソースを分ける必要があり、
|
25
25
|
is_singleに上記のスラッグ名を入れたところ条件外となってしまいます。
|
26
26
|
|
27
27
|
また、各店舗ごとのアーカイブページについては方法が全くわかっていない状態です。
|
28
|
-
```
|
29
28
|
|
30
29
|
よろしくおねがいします。
|