Title: Notice when wp_debug activated
Last modified: September 17, 2020

---

# Notice when wp_debug activated

 *  [jaroat](https://wordpress.org/support/users/jaroat/)
 * (@jaroat)
 * [6 years ago](https://wordpress.org/support/topic/notice-when-wp_debug-activated/)
 * Hi –
 * Did take a look at your plugin and noticed that it throws a PHP notice while 
   WP_DEBUG is enabled:
 * <b>Notice</b>: Trying to get property ‘post_name’ of non-object in <b>/var/www/
   73/skimo/htdocs/wp-content/plugins/wp-api-menus/includes/wp-api-menus-v2.php</
   b> on line <b>390</b><br />
 * Best from Salzburg,
 * – Johannes

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

 *  Thread Starter [jaroat](https://wordpress.org/support/users/jaroat/)
 * (@jaroat)
 * [6 years ago](https://wordpress.org/support/topic/notice-when-wp_debug-activated/#post-13419420)
 * Hi –
 * Seems to be a problem if a nav menu item doesn’t refer to a wp_posts entry.
 * In my case, the menu item was linked to a category (resulting in a link to the
   category overview page) so the object_id doesn’t refer to a wp_posts row but 
   on a wp_term instead. get_post fails in that case and returns null.
 * A possible solution would be to extend the format_menu_item function a little
   bit so it differentiates between the possible menu-item-types (taxonomy, custom,
   post_type, etc.).
 * Best from Salzburg!
 * – Johannes
 *  Thread Starter [jaroat](https://wordpress.org/support/users/jaroat/)
 * (@jaroat)
 * [6 years ago](https://wordpress.org/support/topic/notice-when-wp_debug-activated/#post-13419646)
 * Something like this should do it:
 *     ```
       switch ( $item[ 'type' ] ) {
   
                       case 'post_type':
   
                           $post = get_post( $item['object_id'] );
   
                           $menu_item = array(
                               'id'          => abs( $item['ID'] ),
                               'order'       => (int) $item['menu_order'],
                               'parent'      => abs( $item['menu_item_parent'] ),
                               'title'       => $item['title'],
                               'url'         => $item['url'],
                               'attr'        => $item['attr_title'],
                               'target'      => $item['target'],
                               'classes'     => implode( ' ', $item['classes'] ),
                               'xfn'         => $item['xfn'],
                               'description' => $item['description'],
                               'object_id'   => abs( $item['object_id'] ),
                               'object'      => $item['object'],
                               'object_slug' => $post !== null ? $post->post_name : '',
                               'type'        => $item['type'],
                               'type_label'  => $item['type_label'],
                           );
   
                           break;
   
                       default:
   
                           $menu_item = array(
                               'id'          => abs( $item['ID'] ),
                               'order'       => (int) $item['menu_order'],
                               'parent'      => abs( $item['menu_item_parent'] ),
                               'title'       => $item['title'],
                               'url'         => $item['url'],
                               'attr'        => $item['attr_title'],
                               'target'      => $item['target'],
                               'classes'     => implode( ' ', $item['classes'] ),
                               'xfn'         => $item['xfn'],
                               'description' => $item['description'],
                               'object_id'   => abs( $item['object_id'] ),
                               'object'      => $item['object'],
                               'object_slug' => null,
                               'type'        => $item['type'],
                               'type_label'  => $item['type_label'],
                           );
   
                           break;
   
                   }
       ```
   
    -  This reply was modified 6 years ago by [jaroat](https://wordpress.org/support/users/jaroat/).

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

 The topic ‘Notice when wp_debug activated’ is closed to new replies.

 * ![](https://ps.w.org/wp-api-menus/assets/icon-256x256.png?rev=1070279)
 * [WP API Menus](https://wordpress.org/plugins/wp-api-menus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-api-menus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-api-menus/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-api-menus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-api-menus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-api-menus/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [jaroat](https://wordpress.org/support/users/jaroat/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/notice-when-wp_debug-activated/#post-13419646)
 * Status: not resolved