The global $post can be null e.g. on 404 pages.
if ( ! isset( $this->templates[ get_post_meta( $post->ID, '_wp_page_template', true ) ] )
can therefore generate the error:
Trying to get property of non-object
There should be at least an extra check, e.g. to make sure it’s a
WP_Postinstance or a restriction to only consider those template parts that can use the blank slate template.
I also wonder if more specific types of filter would help here, e.g.
$typecan be e.g.
single, singular, page, ...
- The topic ‘Trying to get property of non-object’ is closed to new replies.