All you need to do is to write a shortcode add wrap a function around it:
function get_post_details($atts) {
// Get the shortcode's attributes
$atts = shortcode_atts( array(
'post' => 0,
), $atts, 'get-post-details' );
// Fetch the ID from $atts array
$id = $atts['post'];
// Stop the shortcode if no ID is set
if ($id == '0') return 'Please provide a post ID.';
// Get the title for this post
$data = get_the_title($id);
// Get the permalink for this post
$data .= get_the_permalink($id);
// Get the thumbnail for this post
$data .= get_the_post_thumbnail_url($id, 'thumbnail');
// Return the data
return $data;
}
add_shortcode( 'get-post-details', 'get_post_details' );
Now you can have a post’s details by using [get-post-details post="123"]
. If no ID is set, the details of the current post in the loop will be shown.