pre_get_shortlink
Filter HookDescription
Filters whether to preempt generating a shortlink for the given post. Returning a value other than false from the filter will short-circuit the shortlink generation process, returning that value instead.Hook Information
File Location |
wp-includes/link-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 4158 |
Hook Parameters
Type | Name | Description |
---|---|---|
false|string
|
$return
|
Short-circuit return value. Either false or a URL string. |
int
|
$id
|
Post ID, or 0 for the current post. |
string
|
$context
|
The context for the link. One of 'post' or 'query', |
bool
|
$allow_slugs
|
Whether to allow post slugs in the shortlink. |
Usage Examples
Basic Usage
<?php
// Hook into pre_get_shortlink
add_filter('pre_get_shortlink', 'my_custom_filter', 10, 4);
function my_custom_filter($return, $id, $context, $allow_slugs) {
// Your custom filtering logic here
return $return;
}
Source Code Context
wp-includes/link-template.php:4158
- How this hook is used in WordPress core
<?php
4153 * @param false|string $return Short-circuit return value. Either false or a URL string.
4154 * @param int $id Post ID, or 0 for the current post.
4155 * @param string $context The context for the link. One of 'post' or 'query',
4156 * @param bool $allow_slugs Whether to allow post slugs in the shortlink.
4157 */
4158 $shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs );
4159
4160 if ( false !== $shortlink ) {
4161 return $shortlink;
4162 }
4163
PHP Documentation
<?php
/**
* Filters whether to preempt generating a shortlink for the given post.
*
* Returning a value other than false from the filter will short-circuit
* the shortlink generation process, returning that value instead.
*
* @since 3.0.0
*
* @param false|string $return Short-circuit return value. Either false or a URL string.
* @param int $id Post ID, or 0 for the current post.
* @param string $context The context for the link. One of 'post' or 'query',
* @param bool $allow_slugs Whether to allow post slugs in the shortlink.
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/link-template.php
Related Hooks
Related hooks will be displayed here in future updates.