Need help? Check out our Support site, then


foreach terms of taxonomy = empty result...

  1. Hello,

    i'm trying to show all the elements from a taxonomy, for example, i have different movies, each classified into a taxonomy as : "comedy", "drama" etc.
    if i'm viewing a page that is part of the "comedy" taxonomy, i would like to have all the others movies from the same taxonomy, so in this example, all the movies linked to "comedy".

    I'm trying to use get_the_term_list to catch the name of the current taxonomy of the page, and then use it with get_terms and a foreach method, to show the result inside a "li" element, but i only got an empty result, (while the get_the_term_list shows me the right taxonomy if i 'echo' it, and if i try with the main taxonomy as a parameter of get_terms, i got the 2 type of taxonomy : comedy and drama inside the "li"s, BUT : i only want what is "inside" the comedy or drama taxonomy, not only the title "comedy" or "drama")

    here's the code :

    $my_tax = get_the_term_list( $post->ID, 'type');
    //echo $my_tax;?> output works fine
    
    $terms = get_terms('$my_tax');
    foreach ($terms as $term) {
    echo "
    ".$term->name."
    "; //it's an empty output

    I don't know how to fix my problem, it is the same thing, i assume, as doing a "related articles" at the bottom of a page, does anyone know how to do this?

    Thanks a lot.

    Paul

  2. You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you'll find help at the WordPress.org forums.

    If you don't understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It'll help people to answer your question.

    This is an automated message.

Topic Closed

This topic has been closed to new replies.

About this Topic