how to list all custom post types in current category archive (1 post)

  1. lorensson
    Posted 2 years ago #

    Hi guys and gals, couldn't find this elsewhere.

    I've got a site that is using category.php to list custom post types in that category.

    For example, my categories structure is like this:

    - fruit
    -- apples
    --- red
    --- orange
    --- yellow
    --- big
    --- small
    -- bananas
    --- red
    --- orange
    --- yellow
    --- big
    --- small

    - veggies
    -- squash
    --- red
    --- orange
    --- yellow
    --- big
    --- small
    -- carrots
    --- red
    --- orange
    --- yellow
    --- big
    --- small

    And my custom post types are like this:
    – red
    - green
    - big
    - small

    All food types share the same set of custom post types (food attributes). What I'm trying to do is direct people toward my second-level category archives (e.g. Carrots) and list the (custom post type) attributes in that category.

    Here's what I'm using now:

    		$taxonomy = 'category';
    		$param_type = 'category__in';
    		$cat_id = get_query_var('cat');
    		  'orderby' => 'slug',
    		  'order' => 'ASC',
    		  'child_of' => $cat_id
    		$terms = get_terms($taxonomy,$term_args);
    		if ($terms) {
    		  foreach( $terms as $term ) {
    		      "$param_type" => array($term->term_id),
    		      'post_type' => 'big',
    		      'post_status' => 'publish',
    		      'posts_per_page' => -1,
    		      'caller_get_posts'=> 1
    		    $big = null;
    		    $big = new WP_Query($args);
    		    $get_cat_name = get_cat_name($cat_id);
    		    $current_post_date = get_the_date();
    		    if( $get_involved->have_posts() ) {
    		      $cat = get_query_var('cat');
    		      while ($big->have_posts()) : $big->the_post(); ?>
    		       <?php endwhile; } } wp_reset_query(); ?>
    	<?php } ?>

    This has been assembled by a lot of Googling and cut-n-pasting. I'm no PHP guru, but I know a bit.

    My problem right now is that I have to categorize each custom post into a 'red, orange, yellow, big, small' category to get it to show in the category archive.

    What I WANT to do is to get rid of all 3rd level category archives and only categorize the custom post types into the 2nd-level categories (e.g. fruits, veggies).

    Any help greatly appreciated!

Topic Closed

This topic has been closed to new replies.

About this Topic