Title: Taxonomy Dropdown
Last modified: August 20, 2016

---

# Taxonomy Dropdown

 *  Resolved [jasonsweb](https://wordpress.org/support/users/jasonsweb/)
 * (@jasonsweb)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/)
 * Hi!
 * For my custom theme I’m trying to populate a dropdown menu in my meta box with
   my custom taxonomies.
 * I’m using this code to get the custom taxonomies:
    ` $types = get_terms('portfolio-
   category'); $types_array[0] = 'Select all';
 * if ($types) {
    foreach($types as $type) { $types_array[$type->term_id] = $type-
   >name; } }
 * But then I’m getting this error in my WP-admin:
    `Trying to get property of non-
   object`
 * Really, I don’t have any idea what I’m doing wrong??
 * Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/#post-3152947)
 * What if you try
 *     ```
       if ($types) {
        foreach($types as $type) {
         if ( $type ) {
          $types_array[$type->term_id] = $type->name;
         }
        }
       }
       ```
   
 *  Thread Starter [jasonsweb](https://wordpress.org/support/users/jasonsweb/)
 * (@jasonsweb)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/#post-3152948)
 * Thanks for your reply.
    Unfortunately the same error…
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/#post-3152952)
 * I’ve just edited my code, can you try again please?
 *  Thread Starter [jasonsweb](https://wordpress.org/support/users/jasonsweb/)
 * (@jasonsweb)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/#post-3152956)
 * Still not working unfortunately. Getting the same error. 🙁
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/#post-3152958)
 * If you have PHP 4/5, try this
 *     ```
       if ($types) {
        foreach($types as $type) {
         if ( is_object( $type ) ) {
          $types_array[$type->term_id] = $type->name;
         }
        }
       }
       ```
   
 *  Thread Starter [jasonsweb](https://wordpress.org/support/users/jasonsweb/)
 * (@jasonsweb)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/#post-3152993)
 * The error disappeared, but the dropdown list is empty.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Taxonomy Dropdown’ is closed to new replies.

## Tags

 * [dropdown](https://wordpress.org/support/topic-tag/dropdown/)
 * [taxonomy](https://wordpress.org/support/topic-tag/taxonomy/)

 * 6 replies
 * 2 participants
 * Last reply from: [jasonsweb](https://wordpress.org/support/users/jasonsweb/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/taxonomy-dropdown/#post-3152993)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
