So I'm trying to create a shortcode to get specific id and its featured image to display it in a specific page. I want to use shortcode to make it easier for the user to add any post in this page.
I've tried a simple code which works but only display title, I'm not sure how I can get the featured image instead of the title.
function post_shortcode( $atts ) {
extract(
shortcode_atts(
array(
'id' => '',
),
$atts
)
);
if ( isset( $id ) ) {
return '<a href="' . get_permalink( $id ) . '">' . get_the_title( $id ) . '</a>';
}
}
add_shortcode( 'test', 'post_shortcode' );