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 want to show a dropdown in the option's panel for choosing a "featured product category" which is a custom taxonomy. I do this way:

    array("hierarchical" => true,
          "label" => "Catalogs",
          "singular_label" => "catalog",
          "rewrite" => true   ));

and in my theme_options.php i have:

array( "name" => "Homepage featured category",  
      "desc" => "Choose a category from which featured posts are drawn", 
      "id" => $shortname."_feat_cat",  
      "type" => "select",  
      "options" => $wp_tax,  
      "std" => "Choose a category"),

and I can't get the taxonomies list:

$args=array(   'name' => 'Catalogs');

$output = 'names'; // or objects    
$taxonomies = get_taxonomies($args,$output);

$wp_tax = array();  
foreach ($taxonomies as $category_list ) {  
     $wp_tax[$category_list->ID] = $category_list->name; 

array_unshift($wp_tax, "Choose a category");

What's wrong? I can't get it to work :(

share|improve this question
Are you looking for a list of terms, or a list of taxonomies? It sounds like you might have a confusion in terms (pun completely unintentional). – goldenapples Nov 2 '10 at 7:05
up vote 3 down vote accepted

A taxonomy is a group of terms. I think you registered a taxonomy Catalogs, and now you want to list all terms in this taxonomy. You do that with the function get_terms(), not get_taxonomies().

So your $wp_tax array should be filled like this:

$wp_tax = array(-1 => 'Choose a category');
$catalog_terms = get_terms('Catalogs');
if ($catalog_terms) {
    foreach ($catalog_terms as $catalog_term) {
        $wp_tax[$catalog_term->term_id] = $catalog_term->name;
share|improve this answer
It works!!!! :) Thank you very much. My first try was with "$taxonomies = get_terms('theme', 'hide_empty=0');" and obviously it didn't work. – Oterox Nov 9 '10 at 15:22

protected by toscho Nov 3 '12 at 20:32

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.