• Resolved daztayor

    (@daztayor)


    Anyone help with this one.

    I’d like to display a taxonomy term_description on a ‘page template’ – not a taxonomy or post template. The page has a standard loop bringing in the usual page detail. I’m guessing I need to add a second loop specifying which taxonomy terms I’d like to display.
    I’ve trawled the web and found info on how to bring in the description (and an image using a plugin) using taxonomy-XXXX.php but nothing for importing on a page.

    Is this possible or am I approaching this from the wrong angle.

    Many thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • It is not well documented in the Codex, but get_the_terms() will return all the term objects associated with a post. Insert code like this in the loop:

    $terms = get_the_terms($post->ID,'category');
    foreach ($terms as $term) {
       echo "<p>$term->name  $term->description</p>";
    }
    Thread Starter daztayor

    (@daztayor)

    Ok thanks very much for the reply but I’m not sure this will work.
    The problem is the ‘page’ I’m displaying is actually unrelated in real terms to the taxonomy – herein lies my problem.
    I’m thinking I may be better trying to write a widget and attempting to bring in the term description items as if I was printing to a sidebar.
    Thanks again.

    try this kind of things

    $property_cat_list = get_the_term_list( $post->ID, 'speaker', 'Property Category(s): ', ', ', '' );
    
    if ( '' != $property_cat_list ) {
    $property_cat_text = "$property_cat_list
    \n";
    
    echo $property_cat_text ;
    }

    Note: “speaker” is taxonomy

    or you can use

    $terms = get_the_terms($post->ID,'speaker');
    foreach ($terms as $term) {
       echo "<p>$term->name  $term->description</p>";
    }

    http://chinmoy29.wordpress.com/2010/07/02/creating-a-custom-taxonomy/

    Maybe what you need is the get_terms() function. It will get all the terms for a given taxonomy.

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

The topic ‘term_description in a page template’ is closed to new replies.