How can I display a short url of the post in the content arrea like
Shortlink -
instead of the standard
Shortlink - /?p=1234
How can I display a short url of the post in the content arrea like
Shortlink - https://www.example/abc24g4
instead of the standard
Shortlink - http://example/?p=1234
Without a plugin or service? You can't. There's no such thing.
From the documentation for wp_get_shortlink()
(emphasis mine):
This function exists to provide a shortlink tag that all themes and plugins can target. A plugin must hook in to provide the actual shortlinks. Default shortlink support is limited to providing ?p= style links for posts. Plugins can short-circuit this function via the ‘pre_get_shortlink’ filter or filter the output via the ‘get_shortlink’ filter.
Not sure of what you are trying to accomplish.
Sounds like you want to show the "shortlink" of the current post in the current post contents.
Create a shortcode (code below) and add to your templates functions.php file, then add [show_current_page_url] some where in the post contents to display the url.
function show_permalink_for_post( $atts ){
// this gets the current page or posts permalink
$link = get_permalink(get_the_ID());
return $link;
}
add_shortcode( 'show_current_page_url', 'show_permalink_for_post' );