function diwp_create_shortcode_arts_post_type(){
$atts = shortcode_atts( array(
'type' => ' ',
), $atts );
$args = array(
'post_type' => 'arts',
'posts_per_page' => '10',
'post_status' => 'publish',
'tax_query' => array( array(
'taxonomy' => 'Types',
'field' => 'term_id',
'terms' => '10', //(What should I do here, otherwise my code is correct, here I just put category id directly but I wanna display a specific category posts)
) )
);
$query = new WP_Query($args);
if($query->have_posts()) :
while($query->have_posts()) :
$query->the_post() ;
$result .= '<div class="art-item">';
$result .= '<div class="art-image">' . get_the_post_thumbnail() . '</div>';
$result .= '<div class="art-name">' . get_the_title() . '</div>';
$result .= '<div class="art-desc">' . get_the_content() . '</div>';
$result .= '</div>';
endwhile;
wp_reset_postdata();
endif;
return $result;
}
add_shortcode( 'arts-list', 'diwp_create_shortcode_arts_post_type' );