質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,143 @@
|
|
27
27
|
|
28
28
|
|
29
29
|
パーマリンク設定に関することを変更したりすると、404エラーが出るので、そのあたりの問題だと思いますが、何か原因のわかる方はいらっしゃれば教えていただきたいです。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
追記
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
パーマリンクを書き換えるプラグイン『Custom Post Type Permalinks』を使用しています。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
カスタム投稿タイプはfunctions.phpに以下のように設定しています。
|
46
|
+
|
47
|
+
```html
|
48
|
+
|
49
|
+
add_action( 'init', 'create_post_type' );
|
50
|
+
|
51
|
+
function create_post_type() {
|
52
|
+
|
53
|
+
$Supports = [
|
54
|
+
|
55
|
+
'title',
|
56
|
+
|
57
|
+
'editor',
|
58
|
+
|
59
|
+
'thumbnail',
|
60
|
+
|
61
|
+
'revisions'
|
62
|
+
|
63
|
+
];
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
register_post_type('activities',
|
68
|
+
|
69
|
+
array(
|
70
|
+
|
71
|
+
'label' => '活動',
|
72
|
+
|
73
|
+
'public' => true,
|
74
|
+
|
75
|
+
'show_ui' => true,
|
76
|
+
|
77
|
+
'show_in_menu' => true,
|
78
|
+
|
79
|
+
'capability_type' => 'post',
|
80
|
+
|
81
|
+
'rewrite' => array( 'slug' => 'activities'),
|
82
|
+
|
83
|
+
'hierarchical' => true,
|
84
|
+
|
85
|
+
'show_in_rest' => true,
|
86
|
+
|
87
|
+
'query_var' => false,
|
88
|
+
|
89
|
+
'has_archive' => true,
|
90
|
+
|
91
|
+
'exclude_from_search' => false,
|
92
|
+
|
93
|
+
'menu_position' => 5,
|
94
|
+
|
95
|
+
'supports' => $Supports
|
96
|
+
|
97
|
+
)
|
98
|
+
|
99
|
+
);
|
100
|
+
|
101
|
+
register_taxonomy(
|
102
|
+
|
103
|
+
'activities_cat',
|
104
|
+
|
105
|
+
'activities',
|
106
|
+
|
107
|
+
array(
|
108
|
+
|
109
|
+
'hierarchical' => true,
|
110
|
+
|
111
|
+
'label' => '活動カテゴリー',
|
112
|
+
|
113
|
+
'show_ui' => true,
|
114
|
+
|
115
|
+
'query_var' => true,
|
116
|
+
|
117
|
+
'show_in_rest' => true,
|
118
|
+
|
119
|
+
'rewrite' => array('slug' => 'activities'),
|
120
|
+
|
121
|
+
'singular_label' => '活動カテゴリー',
|
122
|
+
|
123
|
+
'show_admin_column' => true
|
124
|
+
|
125
|
+
)
|
126
|
+
|
127
|
+
);
|
128
|
+
|
129
|
+
register_post_type('works',
|
130
|
+
|
131
|
+
array(
|
132
|
+
|
133
|
+
'label' => '仕事',
|
134
|
+
|
135
|
+
'public' => true,
|
136
|
+
|
137
|
+
'show_ui' => true,
|
138
|
+
|
139
|
+
'show_in_menu' => true,
|
140
|
+
|
141
|
+
'capability_type' => 'post',
|
142
|
+
|
143
|
+
'rewrite' => array( 'slug' => 'works'),
|
144
|
+
|
145
|
+
'hierarchical' => true,
|
146
|
+
|
147
|
+
'show_in_rest' => true,
|
148
|
+
|
149
|
+
'query_var' => false,
|
150
|
+
|
151
|
+
'has_archive' => true,
|
152
|
+
|
153
|
+
'exclude_from_search' => false,
|
154
|
+
|
155
|
+
'menu_position' => 5,
|
156
|
+
|
157
|
+
'supports' => $Supports
|
158
|
+
|
159
|
+
)
|
160
|
+
|
161
|
+
);
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
add_rewrite_rule('activities/([^/]+)/page/([0-9]+)/?$', 'index.php?activities_cat=$matches[1]&paged=$matches[2]', 'top');
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
```
|