[category_post_count term_id=”1″ taxonomy_name=”category” post_type=”post” number_post=”10″]
function get_post_by_categories( $atts ) {

	//Shortcode attributes
	$atts = shortcode_atts( array(
		'term_id' => null,
		'taxonomy_name' => null,
		'post_type' => null,
		'number_post' => null
	), $atts );

	//Attributes into a variable
	$term_id = $atts['term_id'];
	$taxonomy_name = $atts['category'];
	$post_type = $atts['post_type'];
	$number_post = $atts['number_post'];

	//Getting terms by ID
	$terms = get_term_by('id', $term_id, $taxonomy_name);

	//Get child terms by ID
	$termchildren = get_term_children( $term_id, $taxonomy_name );

	//Output data into a accorion design 
	$output = '
<div class="col-md-3">
<div class="panel panel-default">
';
	$output .= '
<div class="panel-heading">
	
<h4 class="panel-title"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#ubersicht"> Übersicht </a> </h4>

	</div>

';
	$output .= '
<div id="ubersicht" class="panel-collapse collapse in">
<div class="panel-body">
';
	$output .= '
<ul class="asidepostlist">';

	foreach ( $termchildren as $child ) {
		$term = get_term_by( 'id', $child, $taxonomy_name );
		$output .= "
<li>";
		$output .= $term->name;

		$pages = get_posts(array(
			'post_type' => $post_type,
			'numberposts' => $number_post,
			'tax_query' => array(
				array(
					'taxonomy' => $taxonomy_name,
					'field' => 'id',
					'terms' => $term->term_id,
				))
		));
		$output .= '
<ul>';
		foreach ($pages as $key => $values) {
			$output .= '
<li><a href=' . get_permalink($values->ID) . '>' . $values->post_title . '</a></li>

';
		}
		$output .= '</ul>

';
		$output .= "</li>

"; 
	}
	$output .= '</ul>
<div></div>
</div>
</div>

';
	echo $output;
	wp_reset_postdata();

}
add_shortcode( 'get_post_by_tree_view', 'get_post_by_categories' );