內容簡介
此外掛會自動生成一個獨特且隨機的字串並將其設為文章的 post_name。
透過鉤子進行自定義
使用過濾鈎子時需謹慎操作。
您可以將 post_type 改為需要套用的陣列。預設值為「post」。
add_filter( 'random_post_name_post_types', 'hoge' );
function hoge(){
return ['post', 'page'];
}
您可以更改 post_name 中的字元數,預設值為 10。
add_filter( 'random_post_name_digits', 'hoge' );
function hoge(){
return 20;
}
您可以更改字元的變化。預設值為「0123456789abcdefghijklmnopqrstuvwxyz」。請勿包含多位元組字元。
add_filter( 'random_post_name_choices', 'hoge' );
function hoge(){
return '0123456789abcdefghijkmnpqrstuvwxyz_-';
}
注意事項
字元數過少或字元變化過少可能會導致意外問題。
外掛標籤
開發者團隊
原文外掛簡介
Auto-generate a unique random string and set it to post_name.
Customization with hooks
Use of filter hooks is at your own risk.
You can change post_type to be applied by an array. Deafult is ‘post’ only.
add_filter( 'random_post_name_post_types', 'hoge' );
function hoge(){
return ['post', 'page'];
}
You can change the number of characters in the post_name. Deafult is 10.
add_filter( 'random_post_name_digits', 'hoge' );
function hoge(){
return 20;
}
You can change the variation of characters. Deafult is ‘0123456789abcdefghijklmnopqrstuvwxyz’. Do not include multibyte chars.
add_filter( 'random_post_name_choices', 'hoge' );
function hoge(){
return '0123456789abcdefghijkmnpqrstuvwxyz_-';
}
Precautions
Too few characters and too few character variations can cause unexpected problems.
