[WordPress] 外掛分享: Random Post Name

首頁外掛目錄 › Random Post Name
10+
安裝啟用
尚無評分
2105 天前
最後更新
問題解決
WordPress 5.4+ PHP 7.1.24+ v1.0 上架:2020-06-11

內容簡介

此外掛會自動生成一個獨特且隨機的字串並將其設為文章的 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_-';
}

注意事項

字元數過少或字元變化過少可能會導致意外問題。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Random Post Name」→ 直接安裝(推薦)

原文外掛簡介

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.

文章
Filter
Mastodon