I am generating the following notice in my options.php when testing my theme in wp_debug mode.

I can see where the problem is but do not know how to fix this issue?

It seems the non object is being called from the taxonomy array in options.php as the array cannot find the term_id because a post and or category has not been created in the custom post type. When I create a post and assign a category to it, the notice disappears.

// Pull all the custom taxonomies into an array
$options_password_taxonomies = array();
$taxonomies_password_terms_obj = get_terms('password_gallery_category');
foreach ( $taxonomies_password_terms_obj as $taxonomy) {
    $options_password_taxonomies[$taxonomy->term_id] = $taxonomy->name;

// Select a Category for your Client Area
$options[] = array(
    'name' => __('Password Protected Galleries', 'shutter'),
    'desc' => __('Choose a category for password protected client galleries.',     'shutter'),
    'id' => 'client_area',
    'type' => 'select',
    'options' => $options_password_taxonomies);

You can use isset() or property_exists() to check if the property exists.

foreach ( $taxonomies_password_terms_obj as $taxonomy) {
    if( isset( $taxonomy->term_id ) ){
        $options_password_taxonomies[$taxonomy->term_id] = $taxonomy->name;
  • Thanks for this. It fixes the issue but generates a new notice. Should i post this as a new question? Notice: Undefined index: homepage_feature in /inc/options-framework.php on line 313 – Dean McCann Feb 27 '13 at 10:38
  • Yes you should post as a new question. Before, go to that line and use another isset() before using that array variable. It should be fixed. – RRikesh Feb 27 '13 at 10:40
  • Thanks. I can see there is an isset() already in options-framework.php - but this doesn't seem to make a difference. if ( ! isset( $option['id'] ) ) { continue; } – Dean McCann Feb 27 '13 at 10:47
  • ok, I entered a new isset() for term_id and this seems to remove the errors. thank you for introducing me to the magic of isset() :) – Dean McCann Feb 27 '13 at 10:50
  • ok this actually didnt resolve my second issue, so will repost another question. – Dean McCann Feb 27 '13 at 12:40

useisset($variable_to_check) or use is_array($variable_to_check) before proceding foreach because foreach only works with an array of data ie your variable need members

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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