WordPress.org

Support

Support » How-To and Troubleshooting » category.php not working when category taxonomy is assigned to custom post type

category.php not working when category taxonomy is assigned to custom post type

  • I assigned the category taxonomy to a custom post type but now the category.php template isnt displaying any of the custom post type posts.

    I have also tried to create a template named taxonomy-category.php but it does not work.

    I am dependent on having the category taxonomy assigned to this custom post type because I am using the “Category & Page I c o n s” plugin so the client is able to upload icons for each category item (this plugin only allows you to upload icons for the category taxonomy, and unfortunately not for custom taxonomies).

    Below is my category.php template code
    (I have also tried eliminating the query_posts function before the loop but it too does not work)

    <?php get_header(); ?>
      <?php
        $postType = 'directory_entries';
        $postTypeName = 'Directory';
        $cat = get_query_var('cat');
        $category = get_category($cat);
      ?>
      <h2 id="page_title" class="page_title"><?php print $category->name ?> Directory Entries <?php print $category->term_id ?></h2>
      <div id="<?php print $postType ?>" class="clearfix">
          <strong>In category.php template</strong>
            <?php
          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                query_posts('cat='.get_query_var('cat').'&paged='.$paged);
                get_template_part( 'directory_entries', 'loop' );
        ?>
      </div><!-- #<?php print $postType ?> -->
        <strong>Category var_dump:</strong><br /><pre><?php var_dump($category)?></pre>
      <?php get_search_form(); ?>
    <?php get_footer(); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘category.php not working when category taxonomy is assigned to custom post type’ is closed to new replies.