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

I'm using the WooCommerce plugin with WordPress and within my theme I'd like to list all categories within a navigation menu with PHP.

I've tried using woocommerce_product_categories();

but I don't want the images, or other HTML elements, just their names (and maybe permalinks).

How can I get that data?

share|improve this question
up vote 15 down vote accepted

taken from that very same function:

$args = array(
    'number'     => $number,
    'orderby'    => $orderby,
    'order'      => $order,
    'hide_empty' => $hide_empty,
    'include'    => $ids

$product_categories = get_terms( 'product_cat', $args );

will give you the list of product categories. easy!

share|improve this answer
Awesome! Thank you. Just to clear things up for any readers, just add a foreach after: foreach( $product_categories as $cat ) { echo $cat->name; } – Edd Turtle Apr 2 '13 at 10:42

protected by Community May 21 '14 at 10:56

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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