query_vars

過濾鉤子
apply_filters( 'query_vars', $this->public_query_vars )
引數
  • (string[]) $public_query_vars The array of allowed query variable names.
    Required:
定義位置
相關勾子
wp_link_query_argsrest_query_var-keyexport_argsquery_loop_block_query_varsdate_query_valid_columns
相關方法
get_query_varset_query_varadd_query_argquery_postsremove_query_arguser_can
引入
1.5.0
棄用
-

query_vars – 這是一個過濾器鉤子,允許開發者在WordPress查詢中新增自定義查詢變數。這在開發自定義模板或自定義文章型別時很有用,因為它允許你通過URL向模板傳遞資訊。

在處理前對允許的查詢變數進行過濾。

允許(公開允許的)查詢變數在執行查詢之前被新增、刪除或更改。需要允許使用你自己的引數的自定義重寫規則工作,或任何其他你想要公開的自定義查詢變數。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars );
$this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars );
$this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars );

常見問題

FAQs
檢視更多 >