The idea here is to be able to use the Link button to search through posts as usual, but, once selected, use the shortlink (with something like wp_get_shortlink();) instead of the permalink:

<a href="http://example.com/?p=1234">The Link</a>

Not sure if it would be easier to add this function to the existing button or add a new button with this dedicated behavior.

2 Answers 2


If you mean the link dialog, then we can modify the permalinks with the wp_link_query filter:

add_filter( 'wp_link_query', function( $results )
    foreach( $results as &$result )
        $result['permalink'] = wp_get_shortlink( $result['ID'] );

    return $results;
} );

where we use wp_get_shortlink() to get the short links.


You'd go with new button, which will place i.e. [post_shrtl] anywhere in content area (or you can add that phrase manually without button). And then just add this code in funcitons.php:

add_shortcode('post_shrtl', function($atts){
    return $GLOBALS['post']->guid;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.