Reference Shortcode
// Add Shortcode
function reference_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'page' => '',
),
$atts,
'ref'
);
// WP_Query arguments
$args = array(
'post_type' => array( 'reference' ),
'nopaging' => true,
'order' => 'DESC',
'orderby' => 'date',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'Referencer',
'field' => 'term_id',
'include_children' => true,
),
),
'cache_results' => true,
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// do something
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
}
add_shortcode( 'ref', 'reference_shortcode' );