Support » Themes and Templates » custom post types, taxonomies -trying to display all posts in current category

  • Im having the hardest time trying to figure this out.

    Im just trying to create a list of all the “custom post type” posts belonging to the current category linked to “custom post type” post.

    Its the custom post types that’s really throwin me for a loop.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Jonathan Christopher just wrote two thorough tutorials on working with custom post types and custom taxonomies. These will probably help you.

    http://mondaybynoon.com/2010/09/06/custom-post-types-taxonomies-permalinks-wordpress/
    http://mondaybynoon.com/2010/09/06/wordpress-archive-pages-taxonomy/

    Thread Starter isaachorton

    (@isaachorton)

    I cant find the code to simply list all the (custom-post-type)titles with links in a particular custom taxonomy.

    For instance, I want to have a list of associated posts in a particular category but the category is a custom taxonomy and the posts are a custom post type. What would be the code to list just titles with links from the associated category?

    Also, is there a way to define the current category in a custom taxonomy? Let’s pretend that there is always only one category in each taxonomy associated with each post. I want to define the current category within a defined custom taxonomy… then list all it’s contents. Is there a way to do that?

    These custom posts/taxonomies have me scratching my head a bit…. lol!

    Thread Starter isaachorton

    (@isaachorton)

    i was thinking of modifying this bit… any suggestions?

    // Get the selected terms for the post (if has more than one use the first)
    $term = wp_get_object_terms($post->ID, 'Filters');
    
    if ( $term ) { $term = $term[0]; }
    
    //now you can use $term->slug, $term->name, $term->term_id, etc
    Thread Starter isaachorton

    (@isaachorton)

    <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    
    query_posts($query_string . "&cat=".$term->term_taxonomy_id);
    ?>

    Ok so how do i edit this to display the posts in the custom taxonomy?

    Thread Starter isaachorton

    (@isaachorton)

    ok figured it out. wasnt displaying becuase of the php function above it in the template.

    this is solved.

    Thread Starter isaachorton

    (@isaachorton)

    ok i was wrong I cant get this to work anybody have a snippet of code for this?

    Thread Starter isaachorton

    (@isaachorton)

    The code below lists out all the terms in the taxonomy, but Id like to list only the associated post-types in the CURRENT category. In this case my taxonomy is “courses” and I just want to define the current term in “courses” and list the rest of the pages accordingly.
    any clues how to accomplish this?

    <li id="brands" class="widget-container">
      <?php $cam_brands = get_terms('courses', 'hide_empty=1'); ?>
      <ul>
        <?php foreach( $cam_brands as $brand ) : ?>
          <li>
            <a href="<?php echo get_term_link( $brand->slug, 'courses' ); ?>">
              <?php echo $brand->name; ?>
            </a>
            <ul>
              <?php
                $wpq = array( 'post_type' => 'portfolio-item', 'taxonomy' => 'courses', 'term' => $brand->slug );
                $brand_posts = new WP_Query ($wpq);
              ?>
              <?php foreach( $brand_posts->posts as $post ) : ?>
                <li>
                  <a href="<?php echo get_permalink( $post->ID ); ?>">
                    <?php echo $post->post_title; ?>
                  </a>
                </li>
              <?php endforeach ?>
            </ul>
          </li>
        <?php endforeach ?>
      </ul>
    </li>

    I need to do the same, isaachorton did u find a solution?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘custom post types, taxonomies -trying to display all posts in current category’ is closed to new replies.