Wordpress分类法回显输出

I am building a site that will feature sellers, kind of like a deal of the day site, on the product page there will be something that will say this:

"Sold by: (Output Custom Taxonomy for company here)" Every product will have a different brand or company name, but I am just trying to output that taxonomy. Currently I am doing it with the "tags" in wordpress like this:

This works for tags: ---->

<span class="soldBy">Sold By: <?php echo $product->get_tags(); ?> </span>

I then tried this: to get the taxonomy rather then the tags, and it isn't working.

<?php echo $taxonomy->name ?>

Use wp_get_post_terms() for custom taxonomies -- http://codex.wordpress.org/Function_Reference/wp_get_post_terms

An example code:

// assuming your taxonomy is called "company"
$companies      = wp_get_post_terms( get_the_id(), 'company' );
$companies_list = array();

if ( $companies ):
    foreach ( $companies as $company ):
        $companies_list[] = $company->name;
    endforeach; ?>

    <span class="soldBy">Sold By: <?php echo implode( ', ', $companies_list ); ?> </span>

    <?php
endif;

Note: I'm note sure what $product is in your context, so if you are using get_posts() you might want to change the get_the_id() in the code above to $product->ID

So I ended up with this

<?php  
        // assuming your taxonomy is called "company"
        $Brands      = wp_get_post_terms( get_the_id(), 'brand' );
        $Brands_list = array();
        
        if ( $Brands ):
        foreach ( $Brands as $Brands ):
        $Brands_list[] = $brand->name;
        endforeach; ?>

        <span class="soldBy">Sold By: <?php echo implode( ', ', $Brands_list ); ?> </span>

        <?php
        endif; 
        ?>

And it ouputs nothing. Within brands I have three terms or brands. Brand1, Brand2 and Brand3. Still not returning anything.

</div>