Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i need some help how can i display custom taxonomies on selected pages? i mean i have 3 custom taxonomies location,duration & courses i have created three pages where i want to display the terms of these custom taxonomies, i have displayed it on my posts by using function

<?php echo do_shortcode("[terms]"); ?>

but same thing i want to make display on my pages also, how can i do that??????

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If you want to display a list of all terms in a taxonomy, you can call wp_list_categories() and pass the taxonomy argument to get anything other than the categories:

wp_list_categories( array(
    'taxonomy' => 'your-taxonomy'
) );

If you want to use a shortcode for this, so you can use it in your post content, use add_shortcode(). This untested example code allows you to use [taxonomy_terms] or [taxonomy_terms taxonomy=my-taxonomy] in your content:

add_shortcode( 'taxonomy_terms', 'wpse4668_taxonomies' );
function wpse4668_taxonomies( $atts )
{
    // Sanitize our input
    $atts = shortcode_atts( array(
        'taxonomy' => 'your-default-taxonomy',
    ), $atts );
    // Don't echo the output, just return it
    $atts['echo'] = 0;

    return wp_list_categories( $atts );
}
share|improve this answer
    
hey thanks u helped me, –  ntechi Nov 30 '10 at 14:23
    
thanks u helped me but i have one more question, i used the method wp_list_categories, but in the heading it is showing Categories where as it is my custom taxonomies, i want that to be printed how can i do that? –  ntechi Nov 30 '10 at 14:25
    
@ntechi: In the linked codex page you can see that wp_list_categories() accepts a title_li parameter that you can set. You can even expand the shortcode handler to automatically get this from the definition of the taxonomy. –  Jan Fabry Nov 30 '10 at 15:06
    
thanks for your help, –  ntechi Dec 1 '10 at 10:22
    
it is done can you help me in a plugin wordpress.stackexchange.com/questions/4723/need-plugin-help this is the question –  ntechi Dec 1 '10 at 10:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.