WordPress.org

Ready to get started?Download WordPress

Forums

category.php not working when category taxonomy is assigned to custom post type (5 posts)

  1. kjmeath
    Member
    Posted 3 years ago #

    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(); ?>
  2. Pedro Candeias
    Member
    Posted 3 years ago #

  3. kjmeath
    Member
    Posted 3 years ago #

    I know how to use custom taxonomies. As explained above, I want to stick with using the category taxonomy because of the category term icon plugin im using....

  4. Pedro Candeias
    Member
    Posted 3 years ago #

    I'm sorry, i didn't understand at first. Can't help you.
    But, i would try to hack the plugin and make it support custom taxonomies.
    Good luck

  5. dolby_uk
    Member
    Posted 3 years ago #

    I have had the same issue. I'm still debugging it, however if I do a print_r($wp_query), it shows me that it's querying the posts post type, instead of all post types.

Topic Closed

This topic has been closed to new replies.

About this Topic