Skip to content

Instantly share code, notes, and snippets.

@codersaiful
Created July 14, 2018 15:11
Show Gist options
  • Save codersaiful/5805a80a3626773c9240d57c8ce26948 to your computer and use it in GitHub Desktop.
Save codersaiful/5805a80a3626773c9240d57c8ce26948 to your computer and use it in GitHub Desktop.
<?php
$post_imit_each_column = 4;
/**
* To get all Categores as Array,
* Each array Item will be Object - Remember it
* Tuts for: https://www.facebook.com/groups/rrfoundation/permalink/1714332322007066/
* And: https://www.facebook.com/groups/UFTalent/permalink/401160307058625/
*
* @author Saiful Islam<[email protected]>
*/
$categories = get_categories();
foreach ($categories as $category) {
$cat_number = $category->cat_ID; //Cat ID/ Term_ID
$your_catname = get_cat_name($cat_number); //If you want to show your category name any where.
//You can display your cat as your style
$args = array(
//All other here
'cat' => $cat_number,
'posts_per_page' => $post_imit_each_column, //4 or your wish
);
$query = new WP_Query($args);
if ($query->have_posts()) : while ($query->have_posts()): $query->the_post();
/**
* Your Desired execution here.
* Thanks
* @author Saiful Islam<[email protected]>
*/
endwhile;
wp_reset_query();
else:
//Nothing found
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment