Reputation: 1819
i have a custom post type category and its name is donations and donations category has 50 posts. now i want to fetch all those posts any help?
i want to show on template page, name is /Template Name: Help Donations/
i try all of this but its not working for me.
<?php query_posts('category_name=donations&post_type=help'); ?>
<?php while(have_posts()): the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
also this one too is not working.
<?php $the_query = new WP_Query('category_name=donations&post_type=help'); ?>
<?php while($the_query->have_posts()): $the_query->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
Upvotes: 1
Views: 76
Reputation: 3741
Try this. You may need to change the taxonomy name. I just assumed that you named it post_type_category
. So this is to get all post_types with the name help
that has the post_type_category
with the name donations
.
$args = array( 'post_type' => 'help',
'tax_query' => array(
array(
'taxonomy' => 'post_type_category', //don't know if this is right for you
'field' => 'slug',
'terms' => 'donations'
)
)
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;
Upvotes: 1