回答編集履歴
3
修正
test
CHANGED
@@ -10,9 +10,9 @@
|
|
10
10
|
|
11
11
|
```
|
12
12
|
|
13
|
-
function post_slug_tt168889( $slug, $post_
|
13
|
+
function post_slug_tt168889( $slug, $post_id, $post_status, $post_type ) {
|
14
14
|
|
15
|
-
$new_slug = 'co' . $post_
|
15
|
+
$new_slug = 'co' . $post_id;
|
16
16
|
|
17
17
|
return $new_slug;
|
18
18
|
|
2
追記修正
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
投稿の slug は、記事の保存のタイミングで wp_unique_post_slug() 関数で作成され
|
1
|
+
投稿の slug は、記事の保存のタイミングで slug が未入力の場合 wp_unique_post_slug() 関数で作成されます。
|
2
2
|
|
3
|
-
wp_unique_post_slug 関数の中に、wp_unique_post_slug フックが用意されているので、このフックを使うことで任意の slug を設定することが可能になります。
|
3
|
+
wp_unique_post_slug 関数の中に、wp_unique_post_slug フックが用意されているので、このフックを使うことで任意の slug をデフォルトとして設定することが可能になります。
|
4
4
|
|
5
5
|
|
6
6
|
|
1
修正
test
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
投稿の slug は、記事の保存のタイミングで wp_unique_post_slug() 関数で作成されています。
|
2
|
+
|
3
|
+
wp_unique_post_slug 関数の中に、wp_unique_post_slug フックが用意されているので、このフックを使うことで任意の slug を設定することが可能になります。
|
2
4
|
|
3
5
|
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
wp_unique_post_slug フックを利用する場合は、functions.php に下記のように記載します。
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
functions.php に
|
12
8
|
|
13
9
|
|
14
10
|
|
@@ -28,4 +24,4 @@
|
|
28
24
|
|
29
25
|
|
30
26
|
|
31
|
-
[Reference / Hooks / wp_unique_post_slug](https://developer.wordpress.org/reference/hooks/wp_unique_post_slug/)
|
27
|
+
[Reference / Hooks / wp_unique_post_slug](https://developer.wordpress.org/reference/hooks/wp_unique_post_slug/) 参照。
|