3

I just wanted to add this as a SOLVED question because it took me a while to figure it out and there was no documentation on this.

Notice: Trying to get property of non-object in /srv/www/wordpress-default/wp-includes/post.php on line 3555

Trying to wp_update_post() via plugin settings page and was getting this notice.

The solution was to add this line before calling the wp function: $wp_rewrite = new wp_rewrite;

rnevius
  • 26,578
  • 10
  • 58
  • 86
Nick B.
  • 41
  • 6

1 Answers1

1

The solution was to add this line before calling the WP function: $wp_rewrite = new wp_rewrite;

rnevius
  • 26,578
  • 10
  • 58
  • 86
Nick B.
  • 41
  • 6
  • 2
    I think the underlying problem might be that you're calling `wp_update_post()` too early. I ran into this problem and solved it by moving the call to a later hook. `$wp_rewrite` gets instantiated fairly early in bootstrap process, though, so there's probably more to it than that. – Ian Dunn Jan 14 '16 at 23:46
  • @IanDunn Seems to me I can't call that function any later. The function with the wp_update_post() is in a function that fires from a button press and is being called by add_action('init','function')... The fix feels off but I couldn't figure out any other way around it unfortunately. – Nick B. Mar 03 '16 at 18:33
  • I think this answer might help https://wordpress.stackexchange.com/questions/75724/fatal-error-get-page-permastruct – Way Too Simple May 09 '19 at 14:26