-
-
Save mayeenulislam/f1c8459644b294185ceac435d168446a to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Get all the categories first | |
$cat_args=array( | |
'orderby' => 'order', | |
'order' => 'ASC', | |
//'include' => array(2,3,4,5,6,7,8,9,10,11) // use this to display fixed cat only | |
); | |
$categories = get_categories( $cat_args ); | |
// Now query for posts of each category | |
foreach( $categories as $category ) { | |
$args = array( | |
'posts_per_page' => 6, | |
'category__in' => array( $category->term_id ), | |
'ignore_sticky_posts' => 1, | |
'post_status' => 'publish' | |
); | |
$posts = get_posts( $args ); | |
var_dump($posts); | |
} //endforeach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment