jeudi 1 janvier 2015

show custom category posts from a custom post type


I am trying to show posts from a Custom Post Type (documents) that has a custom Taxonomy (subject) with two categories, each category page should have its own posts. But when I open any of these categories page, I get all posts from this Custom Post Type.


I created a file taxonomy-subject.php with below code:



$args = array( 'post_type' => 'documents',
'posts_per_page' => 20 );
$terms = get_terms( 'subject', array (
'hide_empty' => 0,)
);
$loop = new WP_Query( $args, $term );
while ( $loop->have_posts() ) : $loop->the_post();
// content


so where the problem exactly?





Aucun commentaire:

Enregistrer un commentaire