How can I store page ID in a post instead of other selected permalink?

Add that to your functions.php:

function wp_link_query_mod ( $results ){
    if( count( $results ) ){
        for( $i=0; $i<count($results); $i++ ){
            $results[$i]['permalink'] = wp_get_shortlink( $results[$i]['ID'] );
        }
    }
    return $results;
}
add_filter('wp_link_query', 'wp_link_query_mod');

This hook is only usable since WP 3.7, if you have an earlier version then there is an alternative but it would mean changing a line in WP core files.

Leave a Comment