Trying to get property of non-object in dynamic-featured-image.php on line 210
-
I’m using Toolset Types plugin version 1.9.1 alongside with Dynamic Featured Image version 3.5.2. When I create a new post type or edit existing one (posts for example
/wp-admin/admin.php?page=wpcf-edit-type&wpcf-post-type=post
), I get the following error:
Notice: Trying to get property of non-object in ../dynamic-featured-image.php on line 210
In the code, in initialize_featured_box() method (line 204), I’ve added if statement if $post is an object and it resolved the issue.
public function initialize_featured_box() { global $post; //make metabox title dynamic $this->_metabox_title = apply_filters( 'dfi_set_metabox_title', __( "Featured Image" ) ); if (is_object($post)) { $featuredData = get_post_meta( $post->ID, 'dfiFeatured', true ); $totalFeatured = count( $featuredData ); $defaultFilter = array( 'attachment', 'revision', 'nav_menu_item' ); $this->_userFilter = apply_filters( 'dfi_post_type_user_filter', $this->_userFilter ); $filter = array_merge( $defaultFilter, $this->_userFilter ); $postTypes = get_post_types(); $postTypes = array_diff( $postTypes, $filter ); $postTypes = apply_filters( 'dfi_post_types', $postTypes ); if ( ! empty( $featuredData ) && $totalFeatured >= 1 ) { $i = 2; foreach ( $featuredData as $featured ) { self::_dfi_add_meta_box( $postTypes, $featured, $i ); $i ++; } } else { self::_dfi_add_meta_box( $postTypes ); } } } // END initialize_featured_box()
I don’t know how the plugin works in depth, but I believe it make sense to have a look.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Trying to get property of non-object in dynamic-featured-image.php on line 210’ is closed to new replies.