Title: archive-custom_type.php doesn&#039;t work
Last modified: August 21, 2016

---

# archive-custom_type.php doesn't work

 *  Resolved [salgua](https://wordpress.org/support/users/salgua/)
 * (@salgua)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/)
 * Hi
 * I’m relative new to WP. I’m using Custom Post Type UI to manage my custom post
   types. I created a CPT “product” and I checked the “Built-in Taxonomies -> categories”.
   I created some products and relative categories. I also set the option “Has Archive”
   to true. Following [this documentation page](http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates)
   in my theme folder I created a archive-product.php page with a single main loop
   like this:
 *     ```
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
         ....
       ```
   
 * but wordpress load always the archive page instead of this.
    Any idea?
 * [https://wordpress.org/plugins/custom-post-type-ui/](https://wordpress.org/plugins/custom-post-type-ui/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 2 months ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701599)
 * The only things I can think of are issues with the post type slugs not matching
   between what’s registered and the file name, or visiting the wrong url archives.
 * I can’t confirm any of that at the moment though because of no link to visit.
 *  Thread Starter [salgua](https://wordpress.org/support/users/salgua/)
 * (@salgua)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701669)
 * Thank you for your fast answer. I didn’t insert any link because I’m working 
   on a local site. As you suggested I think that the problem is that I’m visiting
   the wrong url. In fact I want to filter my product custom post by category, but
   clicking on a category link the url is [http://mysite/category/mycategory](http://mysite/category/mycategory)
   that’s the standard post category url. I don’t have any category.php file and
   wordpress use the archive.php as fallback. My question is: how can I use standard
   categories to filter custom posts? I tried also using WP_Query in a category.
   php page, in this way:
 *     ```
       $args = array(
       		'post_type' => 'product'
       	);
   
       	$the_query = new WP_Query( $args );
       ```
   
 * and
    `<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query-
   >the_post(); ?>` but the returned loop is always empty.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 2 months ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701676)
 * you’d need to use $the_query->have_posts() in the if statement, for that part.
 * If you explain more about the filtering needs, I can potentially offer a solution.
 *  Thread Starter [salgua](https://wordpress.org/support/users/salgua/)
 * (@salgua)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701681)
 * I have a simple sidebar with the list of products categories, when I click on
   the category link I want to view only the products of this category, in the same
   way that it works for default posts. If I use $the_query->the_post() in the if
   statement it fetch all product posts without filter the current category
 *  Thread Starter [salgua](https://wordpress.org/support/users/salgua/)
 * (@salgua)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701684)
 * Hi Michael, I found
    [this](http://wordpress.org/support/topic/show-categories-filter-on-custom-post-type-list?replies=15)
   What do you think? Maybe is better to use custom taxonomies?
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 2 months ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701687)
 * The thread that you linked to is related to listings in the admin area, not the
   frontend, in case you were trying to copy/paste it directly.
 * Are you familiar with $_GET parameters? An idea to couple with your new WP_Query
   would be to use the sidebar to set the category slug or so and add it to the 
   url:
 *     ```
       http://www.domain.com/?mycat=meow
       http://www.domain.com/?mycat=arf
       ```
   
 * You could then grab that value and put it into the query arguments right before
   the query is made.
 * you’ll need to be careful with what you use in place of mycat because these can
   accidentally alter the original query for the whole page.
 * Hopefully that gives you an idea of how to proceed.
 *  [Craig Pettit](https://wordpress.org/support/users/pushdevadmin/)
 * (@pushdevadmin)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701824)
 * You should use the template hierarchy
 * the template file will be called
    taxonomy-posttype.php
 * or in my case
    taxonomy-portfolio.php

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘archive-custom_type.php doesn't work’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [Craig Pettit](https://wordpress.org/support/users/pushdevadmin/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/archive-custom_typephp-doesnt-work/#post-4701824)
 * Status: resolved