[Plugin: Yet Another Related Posts Plugin] Resolving "Notice: Trying to get property of non-obj
-
If you put WordPress into debug mode with:
define('WP_DEBUG', true);
You may get the following warning
"Notice: Trying to get property of non-object in /yourpath/wp-content/plugins/yet-another-related-posts-plugin/includes.php on line 274"
This appears to be caused by this single line of code:
$type = ($post->post_type == 'page' ? array('page') : array('post'));
My interpretation of the above code is that it attempts to set the variable
$type
based on the object$post
. However,$post
may not actually be an object, if for example you are viewing a regular WordPress page.By rewriting this code with the an
is_object($post)
test, you can avoid this notice.Please note: this also seems to address the following warning:
WordPress database error: [Unknown character set: 'utf'] set names utf-8
- The topic ‘[Plugin: Yet Another Related Posts Plugin] Resolving "Notice: Trying to get property of non-obj’ is closed to new replies.