Display posts of a Sub Category of my taxonomy
I created a Shortcode to display Term of my Taxonomy. But for one of my
taxonomy i have a sub term or sub category. And i don't understand how can
i dusplay posts of a Sub Category of my Taxonomy. Can i help Me please !
Thanks in advance. My Code in functions.php
/*============================================================ LASTS
ARTICLES ============================================================*/
function theme_lasts_posts_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
"posttype" => '',
"taxonomy" => '',
"term" => '',
"class" => '',
"exclude" => '',
), $atts));
$output = '<div class="derniersarticles">';
if ( $posttype != '' ) {
$loop = new WP_Query( array( 'post_type' => $posttype, 'taxonomy' =>
$taxonomy,'term' => $term, 'posts_per_page' => 100, 'post__not_in'
=> array($exclude) ) );
} else {
$loop = new WP_Query( array( 'post_type' => $posttype,
'posts_per_page' => 100 ) );
}
while ( $loop->have_posts() ) : $loop->the_post();
$output .= '<div class="'. $class .'">';
$output .= '<div class="thumb">';
$output .= '<a href="' . get_permalink() . '">' .
get_the_post_thumbnail() . '</a>';
$output .= '</div>';
$output .= '<h3><a href="' . get_permalink() . '">' .
get_the_title() . '</a></h3>';
$output .= '</div>';
endwhile;
$output .= '</div>';
return $output;
}
add_shortcode( 'DerniersArticles', 'theme_lasts_posts_shortcode' );
No comments:
Post a Comment