I have run into a problem where I can no longer create new posts on my WordPress site.
I think this started after a WordPress update a while ago. I also have problems uploading images and I see ghost comments (an icon about new comments but no comments actually showing up in the list).
When clicking on "Posts > Add new" I get a white page with this warning:
"Warning: Creating default object from empty value in /public_html/wp-admin/includes/post.php on line 716"
This is line 716:
$post->post_content = (string) apply_filters( 'default_content', $post_content, $post );
After searching online I think these issues are related to my database. I’m new to dealing with databases, so I’m hoping to maybe be able to get some help here.
Things I’ve tried:
- Using a standard theme
- Disabling all plugins
- Updating WordPress
- Downgrading to WordPress 4.0
- Repairing the database tables
- Running health check I found out that the SQL is old
(5.5.52-MariaDB-cll-lve). Could this be relevant? - Checked the AUTO_INCREMENT box in phpMyAdmin for "wp_posts > structure > ID" and
"wp_postmeta > structure > idmeta_id"
The auto_increment helped remove the error, but instead it caused some new problems. I activated it and could click "Posts > Add new". However, WordPress created multiple copies of the same post, around fifteen posts instead of just one. I trashed them and tried to create a new post, but it still remembered the trashed post and tried to recreate a new post from the post in the trash.
Links I’ve checked and tried:
- https://wordpress.org/support/topic/creating-default-object-from-empty-value-of-line-639-wp-adminincludespostphp/
- https://wordpress.org/support/topic/shoud-wp_posts-id-and-wp_post_meta-meta_id-be-auto_increment/
I feel like this could be relevant as well, but I’m not sure how to make use of it:
8
Answers
Update: Just want to make clear that this is a workaround, I still don't know exactly what the issue was.
Leaving this here in case someone else encounters the same issue. I asked my brother for help and since there were so many weird errors we decided to reinstall wordpress. This is how we did it:
The error is because of the Auto_increment being disabled for the column ID of the table wp_posts. You can enable the Auto Increment option from the PhpMyAdmin.
You could run the following query within the database:
You may also need to enable Auto increment for the table wp_postmeta.
If you are getting the error in post.php line 708
Check the tables auto-increment and primary key feature.
SOLVED upping the memory limit on Mysql
Head to Phpmyadmin dashboard and try to find posts table, (it can also be in the name for example :
abc_posts
), -> go to structure, ->, then select ID, -> if Null is selected to auto increment, deselect, hit save then again, select Auto increment(AI), then save again. Try this, it works for me.I had the same error, and the issue was that the Mysql space was full. I just added more MB to my database and everything worked fine
In my case , did all the things that you say , i found that the next auto increment value was equal to the last post ID( 500 ) in wp_posts table,then i added one to the auto-incremenet value ( 501 ) and sucessful.
I solved this issue on a website I was working on by toggling the Auto Increment in the database. At first I couldn’t create new posts, pages, or upload images. I tried deactivating all plugins and updating everything but still no go. I realized it’s a database issue.
I fixed this by going to wp_posts table in the database. Then go to Structure and then edit the first row which is ID. I then toggled the A_I box and saved.
You can find the breakdown solution here:
http://simplify.quedank.com/how-to-fix-warning-creating-default-object-from-empty-value-in-in-wordpress/