3456
36446
// Add Shortcode
function post_link_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'id' => '',
),
$atts,
'link-to-post'
);
// Return only if has ID attribute
if ( isset( $atts['id'] ) ) {
return '<a href="' . get_permalink( $atts['id'] ) . '">' . get_the_title( $atts['id'] ) . '</a>';
}
}
add_shortcode( 'link-to-post', 'post_link_shortcode' );