WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/the permalink

Description

the_permalink is a filter applied to the permalink URL for a post prior to printing by the function the_permalink.

Note: The output of the functions get_permalink or get_the_permalink is not filtered.

Parameters

$url
(string) (required) The permalink for the current post
Default: None
$post
(integer) (optional) Post ID, WP_Post object, or 0
Default: 0

Examples

Append the query string for the current page to permalink URLs (uses add_query_arg):

function append_query_string($url) {
    return add_query_arg($_GET, $url);
}
add_filter('the_permalink', 'append_query_string');

Change Log

Source Files

This filter is applied by:

Related

This page is marked as incomplete. You can help Codex by expanding it.