'category', 'parent' => 0, 'hide_empty' => 0, ) ); foreach ( (array) $base_categories as $category ) : if ( 0 === $category->count ) { continue; } $output = '
'; $term_link = esc_url( get_term_link( $category ) ); $output .= '

' . $category->name . ' ( ' . sprintf( _n( '%1$s Article', '%1$s Articles', $category->count, 'ItalyStrap' ), number_format_i18n( $category->count ) ) . ' )

'; $output .= '

' . $category->description . '

'; $sub_categories = get_categories( array( 'taxonomy' => 'category', 'parent' => $category->term_id, 'hide_empty' => 0, 'number' => '5', ) ); if ( $sub_categories ) { $output .= ''; } $category_posts = new WP_Query( array( 'posts_per_page' => 5, // 'cat' => $category->term_id, 'category__in' => $category->term_id, ) ); if ( $category_posts->have_posts() ) : $output .= ''; $output .= ' View all'; endif; $output .= '
'; echo $output; // XSS ok. endforeach; ?>