url_to_postid
Filter HookDescription
Filters the URL to derive the post ID from.Hook Information
File Location |
wp-includes/rewrite.php
View on GitHub
|
Hook Type | Filter |
Line Number | 502 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$url
|
The URL to derive the post ID from. |
Usage Examples
Basic Usage
<?php
// Hook into url_to_postid
add_filter('url_to_postid', 'my_custom_filter', 10, 1);
function my_custom_filter($url) {
// Your custom filtering logic here
return $url;
}
Source Code Context
wp-includes/rewrite.php:502
- How this hook is used in WordPress core
<?php
497 *
498 * @since 2.2.0
499 *
500 * @param string $url The URL to derive the post ID from.
501 */
502 $url = apply_filters( 'url_to_postid', $url );
503
504 $url_host = parse_url( $url, PHP_URL_HOST );
505
506 if ( is_string( $url_host ) ) {
507 $url_host = str_replace( 'www.', '', $url_host );
PHP Documentation
<?php
/**
* Filters the URL to derive the post ID from.
*
* @since 2.2.0
*
* @param string $url The URL to derive the post ID from.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/rewrite.php
Related Hooks
Related hooks will be displayed here in future updates.