While testing a plugin of mine with 4.5 RC of WordPress, after turning on debug in wp-config.php, I noticed an error showing up in a core WP file

Notice: Trying to get property of non-object in /wp-includes/post-template.php on line 289

Through process of elimination (turning off all other plugins until finding the message again), I am thinking this is caused by the options page of my plugin (I suppose it could be the main custom post page possibly), but there is no error message to help point me to where. The error points to a core WP file.

This error does not show up everywhere in the admin, only on certain pages such as on the main pages of Plugins, Dashboard, Users, Comments, Appearance, Settings, and on my options page itself, but oddly NOT on any other edit or post pages of my plugin or posts, or pages, or media of the site.

The code on that line in core is

if ( false !== strpos( $post->post_content, '<!--noteaser-->' ) && ( ! $multipage || $page == 1 ) )

and the strange thing is, my options page has no post content relation, only options, so not sure why this function (part of "get_the_content") is even being called. And since there is no more specific error message than the above, nor one that refers to a line in MY code, I am having trouble finding what part of my code could even be kicking this off.

Can someone recommend a way to troubleshoot this better? Some tool with better, more specific error reporting, or things to try to find and fix the problem? I know it is just a NOTICE, and not fatal, but I would still like to fix it if possible.


  • xdebug ? It must be some action/filters!
    – Sumit
    Apr 4, 2016 at 15:01

1 Answer 1


I figured out what was causing this, but it was by trial and error since there was no good debug info. And the error was in the main (custom post calling) part of my plugin, NOT in the options as I had surmised earlier. I ended up finding out that I needed to be using

'content'  => $p->post_content

in my query/foreach loop in place of

'content'  => get_the_content($p->ID)

and that the error line in the original debug (line 289) was failing on a function called "get_the_content" (ie, the one I was using), which ended up being clear after the fact (although it would have been nice if that particular line in my code had been indicated in the debug). Anyway, this would not work without a global $post variable, which caused all kinds of other content problems. But simply pulling the content directly (instead of via the get_the_content function) has solved my issue. Hope this helps someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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