Order posts by category name

I had the same struggle like you, thank i sat down and rethought the whole thing, what you actually need to is select all the categories, and pass the category id to it.

Since you use a dlm_download you will need to do the following, get the terms from the dlm_download_category

$cats = get_terms('dlm_download_category');

Loop trough the category and pass query_posts in it

so

foreach ($cats as $cat) 
{

$args = array(
'post_type' => 'dlm_download',
'dlm_download_category' => $cat->slug,
);

query_posts($args);

if (have_posts()) : 
while (have_posts()) : the_post(); 
// your stuff here
endwhile;
endif; 
}

And there you go

PS: if you want to make it with posts not with custom post

Than $cats = get_categories();

and pass 'cat' in to the argument.

Hope its clear and helps. Cheers

Leave a Comment