Last active
September 7, 2015 17:25
-
-
Save tarikcayir/cb2e433b61b4a32a2821 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Category args. | |
$args = array( | |
'type' => 'post', | |
'child_of' => 0, | |
'parent' => '', | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => 1, | |
'hierarchical' => 1, | |
'exclude' => '', | |
'include' => '', | |
'number' => '', | |
'taxonomy' => 'category', | |
'pad_counts' => false | |
); | |
// Get category list. | |
$categories = get_categories( $args ); | |
// Listing all category. | |
foreach ($categories as $category): ?> | |
<div class="category-item"> | |
<div class="category-item__title"> | |
<?php echo $category->name; ?> | |
</div> | |
<div class="category-item__post-list"> | |
<?php | |
// Query args. | |
$query_args = array( | |
'cat' => $category->term_id, | |
'posts_per_page' => -1, | |
'orderby' => 'date', | |
'order' => 'DESC', | |
); | |
$query = new WP_Query( $query_args ); | |
// Start the loop. | |
while ( $query->have_posts() ) : $query->the_post(); | |
echo get_the_title().'<br/>'; | |
// End the loop. | |
endwhile; | |
?> | |
</div> | |
</div> | |
<?php | |
endforeach; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment