Single Custom Post Shortcode
// Add Shortcode
function storeHotSpot_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'sid' => '123',
),
$atts
);
// WP_Query arguments
$args = array(
'p' => '12',
'post_type' => array( 'stores' ),
);
// The Query
$storeHotSpot = new WP_Query( $args );
// The Loop
if ( $storeHotSpot->have_posts() ) {
while ( $storeHotSpot->have_posts() ) {
$storeHotSpot->the_post();
// do something
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
}
add_shortcode( 'storeHotSpot', 'storeHotSpot_shortcode' );