While I’ve been able to get this working for normal WP categories I’ve been unable to get it working for custom taxonomies.
I’d like to loop through each custom taxonomy (categories in my case) and produce a number of posts for each.
An example of the output would be:
Category 1
post from category one
post from category one
read more category one
Category 2
post from category two
post from category two
read more category two
Of course it would repeat through any available taxonomy for the custom post type.
I thought I would provide another answer as the above one is a little hacky, also I added another layer that gets all taxonomies for a post_type.
It would be recommended to add each post found to a
$post__not_in
array, so you could pass that to theWP_Query
to prevent duplicate posts coming through.Are you looking for this ?
How to create Custom Taxonomy loop
Hope it will help
Copy and paste this function in your functions.php
Then call it from anywhere in your template with:
Please check this example; create a own loop for your taxonomie. You can also use this in a foreach-loop to use all categories. Or you must create an own sql-query.