pre_get_shortlink WordPress Filter Hook

If you're looking to customize the shortlinks that are generated for your WordPress content, the pre_get_shortlink hook is for you. This hook allows you to alter the shortlink before it's generated, giving you full control over its final form. Whether you're looking to add query parameters or change the URL structure entirely, this hook gives you the flexibility to do so.

apply_filters( 'pre_get_shortlink', false|string $return, int $id, string $context, bool $allow_slugs ) #

Filters whether to preempt generating a shortlink for the given post.


Description

Returning a truthy value from the filter will effectively short-circuit the shortlink generation process, returning that value instead.


Top ↑

Parameters

$return

(false|string)Short-circuit return value. Either false or a URL string.

$id

(int)Post ID, or 0 for the current post.

$context

(string)The context for the link. One of 'post' or 'query',

$allow_slugs

(bool)Whether to allow post slugs in the shortlink.


Top ↑

Source

File: wp-includes/link-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More