Skip to content

Instantly share code, notes, and snippets.

@mayeenulislam
Created February 1, 2017 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayeenulislam/f1c8459644b294185ceac435d168446a to your computer and use it in GitHub Desktop.
Save mayeenulislam/f1c8459644b294185ceac435d168446a to your computer and use it in GitHub Desktop.
<?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