Ive been struggling with a wordpress issue for a few weeks now and i just cant figure it out.
I have created a custom post type called ‘cpt_used’, in that custom post type i have created a custom taxonomy called ‘tax_used’, which is a categories list
What i need to do is show all posts that belong to each custom taxonomy and i just cant figure it.
the code i have at the moment is as follows, there are multiple posts in each of the categories, but its just not displaying anything
$args = array(
'orderby' => 'name',
'hide_empty' => 0,
'taxonomy' => 'tax_used'
);
$categories = get_categories($args);
foreach( $categories as $category ) {
$newargs = array(
'category_name' => $category->slug,
'taxonomy' => 'tax_used',
'term' => 'cpt_used'
);
query_posts( $newargs );
if (have_posts()) :
while (have_posts()) : the_post();
the_title();
endwhile;
endif;
}
$newargs are totally messed. try this:
and remember print_r() sometimes returned values to check if it is exactly what you want before you start to iterate it 😉