WordPress.org

Support

Support » Themes and Templates » Taxonomy array dropdown

Taxonomy array dropdown

  • Hi,

    In my admin I would like to add a meta box with a dropdown list of all the custom taxonomies of my portfolio.

    At this moment I’m using this code for the array:

    $types_array = array();
    $types = get_terms('portfolio-category');
    $types_array[0] = 'Select all';
    foreach($types as $type) {
    	if (is_object($type) ) {
    		$types_array[$type->term_id] = $type->name;
    	}
    }

    Problem is that the dropdown menu isn’t displaying the categories, only the option “Select All”. So it’s empty…

    To check if there was a bug in my metabox code, I’ve tested it with tags and pages, like this code:

    $options_tags = array();
    $options_tags_obj = get_tags();
    foreach ( $options_tags_obj as $tag ) {
      $options_tags[$tag->term_id] = $tag->name;
    }

    And this code is working perfect, so there’s a bug in my array. But I’ve been trying for hours now… Somebody who can help me out? Thanks!

  • The topic ‘Taxonomy array dropdown’ is closed to new replies.