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