簡體   English   中英

WordPress自定義頁面URL重寫

[英]WordPress Custom Page URL rewrite

我在wordpress上有自定義頁面,可通過以下方式訪問:

domain.com/custom-page/1

我如何實現以下網址格式:

domain.com/custom-page/1/Title-of-Page-Content

要么

domain.com/custom-page/1-Title-of-Page-Content

似乎在“自定義頁面”之后,則不能接受整數值。

注意:我已經嘗試過.htaccess方式,並在theme / functions.php中添加以下代碼

function custom_rewrite_rule() {
    add_rewrite_rule('custom-page/([^/]*)/([^/]*)?$','index.php?pagename=custom-page&_id=$matches[1]&title=$matches[2]','top');
}
add_action('init', 'custom_rewrite_rule', 10, 0);

任何幫助? 提前致謝。

當您位於Wordpress的“管理”區域時,請轉到“設置”彈出菜單。 固定鏈接有一個選項。 轉到此處,然后為您的頁面提示選擇所需的模式。 我認為您要選擇的具體名稱是郵政名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM