Filters the attachment ID to allow short-circuit the function.
Description
Allows plugins to short-circuit attachment ID lookups. Plugins making use of this function should return:
- 0 (integer) to indicate the attachment is not found,
- attachment ID (integer) to indicate the attachment ID found,
- null to indicate WordPress should proceed with the lookup.
Warning: The post ID may be null or zero, both of which cast to a boolean false. For information about casting to booleans see the PHP documentation.
Use the === operator for testing the post ID when developing filters using this hook.
Parameters
$post_idint|null- The result of the post ID lookup. Null to indicate no lookup has been attempted. Default null.
$urlstring- The URL being looked up.
Source
$post_id = apply_filters( 'pre_attachment_url_to_postid', null, $url );
Changelog
| Version | Description |
|---|---|
| 6.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.