質問編集履歴
3
ファイル変更履歴追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
|
49
49
|
|
50
50
|
|
51
|
-
###追記
|
51
|
+
###追記1
|
52
52
|
|
53
53
|
目標のURL(例:2ページ目)
|
54
54
|
|
@@ -135,3 +135,93 @@
|
|
135
135
|
};
|
136
136
|
|
137
137
|
```
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
###追記2
|
142
|
+
|
143
|
+
Debug Barで確認したページリクエスト
|
144
|
+
|
145
|
+
ローカル(MAMP)
|
146
|
+
|
147
|
+
```
|
148
|
+
|
149
|
+
Request:
|
150
|
+
|
151
|
+
記事スラッグ/x1/y1
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
Query String:
|
156
|
+
|
157
|
+
name=記事スラッグ&cpage=2&y=y2
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
Matched Rewrite Rule:
|
162
|
+
|
163
|
+
([^/]+)/x1(/(.*))?/?$
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
Matched Rewrite Query:
|
168
|
+
|
169
|
+
name=記事スラッグ&y=y1
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
サーバー(functions.phpに追加後)
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
Request:
|
178
|
+
|
179
|
+
記事スラッグ/x1/y1
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
Query String:
|
184
|
+
|
185
|
+
name=記事スラッグ&cpage=-2%2F&y=y2
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
Matched Rewrite Rule:
|
190
|
+
|
191
|
+
([^/]+)/x1(/(.*))?/?$
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
Matched Rewrite Query:
|
196
|
+
|
197
|
+
name=記事スラッグ&y=y1
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
サーバー(functions.phpに追加前)
|
202
|
+
|
203
|
+
```
|
204
|
+
|
205
|
+
Request:
|
206
|
+
|
207
|
+
記事スラッグ/x1/y1/comment-page-2
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
Query String:
|
212
|
+
|
213
|
+
name=記事スラッグ&y=y1%2Fcomment-page-2
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
Matched Rewrite Rule:
|
218
|
+
|
219
|
+
([^/]+)/x1(/(.*))?/?$
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
Matched Rewrite Query:
|
224
|
+
|
225
|
+
name=記事スラッグ&y=y1%2Fcomment-page-2
|
226
|
+
|
227
|
+
```
|
2
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
```
|
36
36
|
|
37
|
-
実際に叩くURLは`http://example.com/x1/y1/?cpage=xxx`になるのですが、`cpage=1`の場合は期待通りコメントの1ページ目が表示されるのですが、2より大きい数値を指定するとWordPressのデフォルトのリライトルールにより`http://example.com/x1/y1/comment-page-2/`になってしまいます。
|
37
|
+
実際に叩くURLは`http://example.com/記事スラッグ/x1/y1/?cpage=xxx`になるのですが、`cpage=1`の場合は期待通りコメントの1ページ目が表示されるのですが、2より大きい数値を指定するとWordPressのデフォルトのリライトルールにより`http://example.com/記事スラッグ/x1/y1/comment-page-2/`になってしまいます。
|
38
38
|
|
39
39
|
|
40
40
|
|
@@ -54,15 +54,15 @@
|
|
54
54
|
|
55
55
|
理想
|
56
56
|
|
57
|
-
`http://example.com/x1/y1/?cpage=2`
|
57
|
+
`http://example.com/記事スラッグ/x1/y1/?cpage=2`
|
58
58
|
|
59
59
|
現状
|
60
60
|
|
61
|
-
`http://example.com/x1/y1/comment-page-2/`
|
61
|
+
`http://example.com/記事スラッグ/x1/y1/comment-page-2/`
|
62
62
|
|
63
63
|
下記my_add_single_rewrite2()追記後
|
64
64
|
|
65
|
-
`http://example.com/x1/y1/?cpage=-2%2F`
|
65
|
+
`http://example.com/記事スラッグ/x1/y1/?cpage=-2%2F`
|
66
66
|
|
67
67
|
|
68
68
|
|
1
質問にて求められたファイル内容の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -45,3 +45,93 @@
|
|
45
45
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
46
46
|
|
47
47
|
WordPress 4.7.8
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
###追記
|
52
|
+
|
53
|
+
目標のURL(例:2ページ目)
|
54
|
+
|
55
|
+
理想
|
56
|
+
|
57
|
+
`http://example.com/x1/y1/?cpage=2`
|
58
|
+
|
59
|
+
現状
|
60
|
+
|
61
|
+
`http://example.com/x1/y1/comment-page-2/`
|
62
|
+
|
63
|
+
下記my_add_single_rewrite2()追記後
|
64
|
+
|
65
|
+
`http://example.com/x1/y1/?cpage=-2%2F`
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
*現状の設定について
|
70
|
+
|
71
|
+
functions.php
|
72
|
+
|
73
|
+
```php
|
74
|
+
|
75
|
+
add_filter('init', 'my_add_single_rewrite1');
|
76
|
+
|
77
|
+
add_filter('init', 'my_add_single_rewrite2');
|
78
|
+
|
79
|
+
add_filter('init', 'my_add_single_rewrite3');
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
function my_add_single_rewrite1() {
|
84
|
+
|
85
|
+
add_rewrite_endpoint('x1', EP_PERMALINK, 'y1');
|
86
|
+
|
87
|
+
add_rewrite_endpoint('x2', EP_PERMALINK, 'y2');
|
88
|
+
|
89
|
+
add_rewrite_endpoint('x3', EP_PERMALINK, 'y3');
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
function my_add_single_rewrite2() {
|
96
|
+
|
97
|
+
global $wp_rewrite;
|
98
|
+
|
99
|
+
$wp_rewrite->comments_pagination_base = '?cpage=';
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
function my_add_single_rewrite3( $array ) {
|
106
|
+
|
107
|
+
add_rewrite_rule('smart-custom-fields/[^/]+/attachment/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
108
|
+
|
109
|
+
add_rewrite_rule('smart-custom-fields/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?smart-custom-fields=$matches[1]&cpage=$matches[2]', 'top');
|
110
|
+
|
111
|
+
add_rewrite_rule('smart-custom-fields/[^/]+/([^/]+)/?cpage=([0-9]{1,})/?$', ' index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
112
|
+
|
113
|
+
add_rewrite_rule('media/[^/]+/attachment/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
114
|
+
|
115
|
+
add_rewrite_rule('media/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?media=$matches[1]&cpage=$matches[2]', 'top');
|
116
|
+
|
117
|
+
add_rewrite_rule('media/[^/]+/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
118
|
+
|
119
|
+
add_rewrite_rule('feature/[^/]+/attachment/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
120
|
+
|
121
|
+
add_rewrite_rule('feature/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?feature=$matches[1]&cpage=$matches[2]', 'top');
|
122
|
+
|
123
|
+
add_rewrite_rule('feature/[^/]+/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
124
|
+
|
125
|
+
add_rewrite_rule('.?.+?/attachment/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
126
|
+
|
127
|
+
add_rewrite_rule('(.?.+?)/?cpage=([0-9]{1,})/?$', 'index.php?pagename=$matches[1]&cpage=$matches[2]', 'top');
|
128
|
+
|
129
|
+
add_rewrite_rule('[^/]+/attachment/([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'top');
|
130
|
+
|
131
|
+
add_rewrite_rule('([^/]+)/?cpage=([0-9]{1,})/?$', 'index.php?name=$matches[1]&cpage=$matches[2]', 'top');
|
132
|
+
|
133
|
+
add_rewrite_rule('[^/]+/([^/]+)/?cpage=([0-9]{1,})/?$ ', 'index.php?attachment=$matches[1]&cpage=$matches[2] ', 'top');
|
134
|
+
|
135
|
+
};
|
136
|
+
|
137
|
+
```
|