Resources Complete Shortcode
// Add Shortcode
function resource_display_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'tag' => '',
),
$atts
);
// WP_Query arguments
$args = array(
'post_type' => array( 'resources' ),
'post_status' => array( 'published' ),
'nopaging' => false,
'posts_per_page' => '6',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'resource-type',
'terms' => 'business',
'field' => 'name',
),
),
);
// 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( 'resources', 'resource_display_shortcode' );