• Having registered a custom taxonomy, how do I output the name/description of all items in that custom taxonomy to a page?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Anonymous User 9055193

    (@anonymized-9055193)

    Please read up on WP_Query. You will love it!

    Example:

    $args = array(
    	'post_type' => 'post',
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'people',
    			'field'    => 'slug',
    			'terms'    => 'bob',
    		),
    	),
    );
    $query = new WP_Query( $args );

    Your specific case: Taxonomy Parameters

    Cheers

    Thread Starter gulliver

    (@gulliver)

    Thanks. More reading… great, just what I need. 😉

    Meantime, this seems to work:

    <?php
    $terms = get_terms("host");
     $count = count($terms);
     if ( $count > 0 ){
         echo "<ul>";
         foreach ( $terms as $term ) {
           $termlinks= get_term_link($term,$taxonomy);
                    ?> <a href="<?php echo $termlinks; ?>">
                    <?php echo "<li>" . $term->name . "</li>"; ?></a><?php
     }
            echo "</ul>";
            }
    ?>

    And I now know that the items in a taxonomy are correctly called ‘terms’.

    Oh, joy. My brain can’t stop smiling. Now, where did I leave the life I used to have?

    Anonymous User 9055193

    (@anonymized-9055193)

    Haha! Yes, read read read read. Terms with a custom WP_Query can be fun in a geeky way. But once you master it, the sky’s the limit! Glad you found a solution.

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

The topic ‘Display items in custom taxonomy’ is closed to new replies.