WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I go to


then I see this code:-

 * Single Product Meta
 * @author      WooThemes
 * @package     WooCommerce/Templates
 * @version     1.6.4

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

global $post, $product;
<div class="product_meta">

    <?php echo $product->get_categories( ', ', ' <span class="posted_in">'.__('Category:', GETTEXT_DOMAIN).' ', '.</span>'); ?>

    <?php echo $product->get_tags( ', ', ' <span class="tagged_as">'.__('Tags:', GETTEXT_DOMAIN).' ', '.</span>'); ?>


What modifications are required so that it doesn't display the category, having slug, certain-category-slug ?

I could have used the following:-

get_categories( array( 'exclude' => 'certain-category-slug' ) )

but I believe that WooCommerce $product->get_categories is different from WordPress API get_categories because their arguments are different.

share|improve this question
up vote 1 down vote accepted

You are right about woocommerce: get_categories() being different from wordpress: get_categories(), the woocommerce function uses get_the_term_list(), so there is no way to exclude categories, same applies to get_the_category_list(). You can use wp_list_categories() for this, especially take a look at this example from the codex page:

Display Categories Assigned to a Post

Display the categories (or terms from other taxonomies) assigned to a post ordered by parent-child category relationship. Similar to the function get_the_category_list() which orders the categories by name. This example must be used inside the loop.


$taxonomy = 'category';

// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator between links
$separator = ', ';

if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {

    $term_ids = implode( ',' , $post_terms );
    $terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
    $terms = rtrim( trim( str_replace( '<br />',  $separator, $terms ) ), $separator );

    // display post categories
    echo  $terms;

This isn't a complete solution, you have to construct a function based on this and use your new function instead of the default inside meta.php.

share|improve this answer
Your answer helped a lot in finding directions. However, I thought that instead of writing so much code just do a quick dirty hack: <?php echo str_replace("Category Name","",$product->get_categories( ', ', ' <span class="posted_in">'.__('Category:', GETTEXT_DOMAIN).' ', '.</span>')); ?> – Omar Tariq Nov 17 '13 at 3:56

Your Answer


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.