rest_{$this->post_type}_collection_params

過濾鉤子
apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type )

rest_{$this->post_type}_collection_params: 這是WordPress中的一個過濾器鉤子,當REST API正在為一個特定的文章型別的文章集合設定引數時被觸發。鉤子名稱中的”{$this->post_type}”部分被替換為文章型別的實際名稱。它允許開發者在返回之前修改集合引數。

過濾文章控制器的集合引數。

過濾器的動態部分$this->post_type是指控制器的post-type slug。

此篩選器註冊集合引數,但不將集合引數對映到內部WP查詢引數。使用“rest{$this->post_type}_query”篩選器設定WP_QUERY引數。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
return apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type );
return apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type );
return apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type );

常見問題

FAQs
檢視更多 >