rest_prepare_attachment

過濾鉤子
apply_filters( 'rest_prepare_attachment', $response, $post, $request )
引數
  • (WP_REST_Response) $response The response object.
    Required:
  • (WP_Post) $post The original attachment post.
    Required:
  • (WP_REST_Request) $request Request used to generate the response.
    Required:
定義位置
相關勾子
rest_prepare_commentrest_prepare_themerest_insert_attachmentrest_prepare_autosaverest_prepare_status
相關方法
prepend_attachmentwp_prepare_attachment_for_jsrest_parse_dateis_attachmentis_local_attachmentget_the_attachment_link
引入
4.7.0
棄用
-

rest_prepare_attachment – 這個鉤子在WordPress的附件(媒體專案)的請求被呼叫。它被用來過濾在請求的響應中返回的資料。開發人員可以使用這個鉤子來新增或修改附件的資料,例如新增額外的欄位或修改現有欄位的資料。

過濾從REST API返回的附件。

允許在附件被返回前對其進行修改。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
return apply_filters( 'rest_prepare_attachment', $response, $post, $request );
return apply_filters( 'rest_prepare_attachment', $response, $post, $request );
return apply_filters( 'rest_prepare_attachment', $response, $post, $request );

常見問題

FAQs
檢視更多 >