WordPress.org

Support

Support » How-To and Troubleshooting » Custom post type and new wp query for category page

Custom post type and new wp query for category page

  • Hi,
    I created a custom template for a category (and children) called cat_mycatname.php

    Here I want to query posts only from a custom post type and with a tag

    <?php
    // The Query
    $cat_id = get_cat_ID();
    $args=array(
      'cat' => $cat_id,
      'post_type' => 'videopagine',
      'tag' => 'space',
    );
    $the_query = new WP_Query( $args );
    while ( $the_query->have_posts() ) : $the_query->the_post();
    
    ?>

    It can’t seem to filter my results as I normally would, it just displays all the entries in that custom post type (in both parent and children cat pages)
    What’s wrong?

  • The topic ‘Custom post type and new wp query for category page’ is closed to new replies.