null, // Default value is null 'link' => 'yes', // Default value is 'yes' (post URL as link) 'class' => '', // Default value is an empty string for the class 'new_window' => 'no', // Default value is 'no' (open link in the same window) ), $atts, 'aio_post_url' ); if (empty($atts['id'])) { // If 'id' attribute is not provided, use the current post ID $post_id = get_the_ID(); } else { // Use the specified post ID $post_id = absint($atts['id']); } $post_url = get_permalink($post_id); if ($atts['link'] === 'yes') { // Use the post URL as a link $post_url = '' . esc_html($post_url) . ''; } else { // Display the plain post URL $post_url = esc_url($post_url); } return $post_url; } add_shortcode('aio_post_url', 'aio_post_url_shortcode');