get_shortlink
Filters the shortlink for a post.
Использование
add_filter( 'get_shortlink', 'wp_kama_get_shortlink_filter', 10, 4 );
/**
* Function for `get_shortlink` filter-hook.
*
* @param string $shortlink Shortlink URL.
* @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. Not used by default.
*
* @return string
*/
function wp_kama_get_shortlink_filter( $shortlink, $id, $context, $allow_slugs ){
// filter...
return $shortlink;
}
- $shortlink(строка)
- Shortlink URL.
- $id(int)
- Post ID, or 0 for the current post.
- $context(строка)
- The context for the link. One of 'post' or 'query',
- $allow_slugs(true|false)
- Whether to allow post slugs in the shortlink. Not used by default.
Список изменений
| С версии 3.0.0 | Введена. |
Где вызывается хук
get_shortlink
wp-includes/link-template.php 4209
return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs );