• I have created a custom post type and a custom taxonomy to go with it.

    How do i go about displaying the name of the custom taxonomy?

    So i have a post from the custom post type and its assigned to one of the taxonomy, when its showing its content, can it also so the taxonomy name, like it would the post title name, or content?

    Could it appear within the following query at all?

    <?php  query_posts( array( 'post_type' => 'film','posts_per_page' => '5' ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <ul id="archive-right">	
    
    <li><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'empty' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    </li>
    
    </ul><!--.video-holder-->
    
     <?php endwhile; endif; wp_reset_query(); ?>

    Thanks for any help 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • you want the term(s) out of the taxonomy? Here’s how I do it…. this block of code can go anywhere really (right below my query is where I put it). The only thing you would need to change in this code is product_category, that is the name of my taxonomy. Change it to yours.

    <?php
    				// Let's find out if we have taxonomy information to display
    				// Something to build our output in
    				$taxo_text = '';   
    
    				// Variables to store each of our possible taxonomy lists
    				// This one checks for a Product Category classification
    				$prodcat_list = get_the_term_list( $post->ID, 'product_category', '', ', ', '' );
    
    				// Add Product Category list if this post was so tagged
    				if ( '' != $prodcat_list )
    				$taxo_text .= $prodcat_list;
    				?>

    This code only builds the list. It displays just one term if there is only one, or a comman separated list if there is more than one term.

    to actually output the list I put:
    <?php echo $taxo_text; ?>
    Where I want the terms to appear

    Thread Starter jezthomp

    (@jezthomp)

    Thats brilliant rev.

    I notice it displays a link, will that got to taxonomy-(taxname).php and simply all the results, as i cannot get anything to show up on that page..?

    Would it be possible to display just the name without the link?

    Thanks again 🙂

    I use a taxonomy-product_category.php template for my custom taxonomy. Clicking the links generated by the code above uses that template. The template itself is really just a standard loop. No special queries or anything. I just needed to use a special sidebar with that taxonomy. Having that single file come up for the taxonomy is default WP behaviour.

    If you want the list generated to be non-links, I believe you swap get_the_term_list with get_the_terms
    http://codex.ww.wp.xz.cn/Function_Reference/get_the_terms

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

The topic ‘Display Custom Taxonomy Name…?’ is closed to new replies.