flush_rewrite_rules

函式
flush_rewrite_rules ( $hard = true )
引數
  • (bool) $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
    Required:
    Default: true
定義位置
相關方法
add_rewrite_rulesave_mod_rewrite_rulesiis7_add_rewrite_ruleiis7_rewrite_rule_existsiis7_save_url_rewrite_rules
引入
3.0.0
棄用
-

flush_rewrite_rules: 這個函式用來重新整理WordPress的重寫規則快取: 當新的自定義文章型別、分類法或重寫規則被新增到一個WordPress站點時,這是必要的。通過重新整理重寫規則快取,新的規則將被處理並用於為新內容生成正確的URL。

移除重寫規則,然後重新建立重寫規則。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function flush_rewrite_rules( $hard = true ) {
global $wp_rewrite;
if ( is_callable( array( $wp_rewrite, 'flush_rules' ) ) ) {
$wp_rewrite->flush_rules( $hard );
}
}
function flush_rewrite_rules( $hard = true ) { global $wp_rewrite; if ( is_callable( array( $wp_rewrite, 'flush_rules' ) ) ) { $wp_rewrite->flush_rules( $hard ); } }
function flush_rewrite_rules( $hard = true ) {
	global $wp_rewrite;

	if ( is_callable( array( $wp_rewrite, 'flush_rules' ) ) ) {
		$wp_rewrite->flush_rules( $hard );
	}
}

常見問題

FAQs
檢視更多 >