I have an issue where all posts that are older than two days are missing. They are not in the trash in Wordpress, and if you go to the URL, it will come back with a 404.
I've tried disabling all plugins and repairing the tables in PHPMyAdmin as well as using the /wp-admin/maint/repair.php
I also have activated wp_debug and looked at the log; however there is nothing relating to this issue.
Now when I check the database in PHPMyAdmin - I can see all the posts there.
I've compared the posts that are currently published to the ones that are missing and the only difference I can see if that the post_status is set to "inherited" opposed to saying "published".
If I update the post_status of a missing post to "published" then edit the post in Wp-admin with the ID, eg, post.php?post=[missing post id]&action=edit it will show the missing post for about 2 seconds (including all the content) then redirect to an edit media page with every field blank.
I assume some plugin made this change, figuring out which one is the hard part.
Let me know if you need any more details from my end.
If a post is not viewable in WP dashboard but searchable in SQL table this could mean a revision has not been published (or the published revision has disappeared from the table). To turn on a revision see you must change post_type to 'post' and post_status to 'publish'
make a post viewable in phpmyadmin
Related
I am currently doing my own wordpress theme and therefore need a custom post order. However, I am able to activate the post attribute's order within the wordpress gutenberg editor with the following code
add_post_type_support('post','page-attributes');
but it does not save when saving the post and always resets back to 0.
I already tried disabling all plugins and also checked the error with another wordpress theme (and the code shown) and another plain wordpress blog but it seems to not save my order set.
I also checked the post within the database and there is "menu_order" set to 0. When changing this manually to 5 or some other number, I can use this parameter for my custom order but gutenberg editor still shows up 0 as post attributes order.
Any ideas what I did wrong or is this a wordpress bug. Any chances to fix this? The order attribute of pages seems to work within gutenberg editor.
With Gutenberg, WordPress is using the REST API to handle data. Because of that, you need to work with two filters to allow you to save that field, and then display the result in the admin. Those two filters are: rest_pre_insert_post and rest_prepare_post.
This is because WordPress has the schemas for the default posts hard-coded, which you can see in /wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php # line 1997. The schema for the default post doesn't include page-attributes. This is the workaround that I came up with for a project that I was working on: https://gist.github.com/jesgs/e619bfbfe10ad998d8a61ac41cc958a7
I have encountered this problem many times. This problem only happen when I programmatically create/edit posts. They could be customs post or even Wordpress' default post. The symptoms could be:
The posts are not visible in admin dashboard. Post count of that custom post type still increase but no post is displayed in the list.
Created posts are not query-able, even when post_status is set to 'any'. Curiously when I set post_status to published it works.
This is a self-answered question. I encountered this problem several times before and always forget its cause. And searches hint to possibilities that many others are stuck without solution too.
TL;DR;: It's publish, not published.
The cause of this problem is because I when programmatically create new posts, I set its post_status to published. Common reason for the confusion is when you approve a post programmatically, switching post status from pending to published because it seem logical.
The reason those posts are showing in neither queries nor admin dashboard is because WP_Query's post_status => 'any' doesn't actually query for 'any' post status as we expect, but any registered post status. Since wordpress had no prior knowledge of the post status published, they're simply ignored by the queries.
Now here's to hope I don't forget what I wrote today again next year.
I followed the below tutorials in order to create a custom post type with custom fields.
https://www.youtube.com/watch?v=-r1b0wA98Ew
https://www.youtube.com/watch?v=6URWfMTsWPo
This worked great and I added lots of data using the forms I'd created and had the data displaying on the front end of the website.
A week ago, the custom post type disappeared from the Admin Menu but the the data seems to be intact from the front-end point of view. I posted a message in the CPT UI wordpress forum and got told to simply re-add the post type and re-link the data back up.
My question is HOW do I re-link the data back up? I have re-added the Custom Post type so its ls listed in the admin menu, but I need to be able to edit the custom posts I have already added. Can anyone help? Not getting much help from the Wordpress forum. Thanks
AS the data is intact in the front end it means the entries are still in database and nothing is lost.
It is correct way to just re-add the missing post-type and WordPress will now automatically re-link/re-connect your existing data, since WordPress is storing custom post type in the wp_posts table with post_type field value to your user-defined value.
Just make sure that the post-type name is same as you used earlier because slight mistake in spelling will lead to data not displayed in admin panel as expected.
You can also post further details which would be helpful to get actual problem found out.
#leetee this has 50/50 chance, experimental and since there is no way to reproduce this behaviour; try exporting your custom post types by using Tools -> Export and then see if you could Import them into a fresh WP install...
I'm am creating a simple administration system for one of my sites, and now I am creating a blog inspired by WordPress' posts system.
In my blog you can save it as either a draft or a published version.
And now I want to create a way, so when you delete a blog, it will change to "trashed" in the database. And when you restore it, it will be restored as the same type again, just like WordPress.
But how do WordPress restore it's trashed posts, to the original post_status? I have looked at the WordPress database, but I couldn't figure out, how it does it, cause the original post_status is replaced with "trash" when it is trashed and is not stored any other place in the table.
So how does it "remember" it's original post_status? Hope you understand what I'm asking :D
Sorry for not being a code-related question, but I couldn't find any answer any other places.
Thanks
To be short:
The previous post-status of a WordPress post, is stored in the wp_postmeta table.
In that table, the time for when the post were trashed, also are stored.
If you then restore the post, the rows of containing data for that specific post, are removed.
That should answer your question.
This is basic stuff to be frank. You should look at the wp_posts table and see the difference between a trashed and a published post ( and possibly, others too). Wordpress does this by changing the post_status column for that particular row of data. This way it knows the current status of the post concerned.
It might not be related to the answer but for those who are looking for answer to this question, should consider looking at the data source, i.e. the database of any system you are trying to learn... Be it Wordpress or Moodle.
All the posts, pages, and cpts are stored in {table_prefix}_postsin the database.
The posts, pages, or cpts which are trashed have the post_status as trash in some cases the permalink is also changed to __trashed
e.g; http://example.com/sample-page__trashed
To restore the post page, change the post_status back to published and remove __trashed from the permalink if it exists.
I recently fixed the issue on the site which was using the 'Frontend User Pro' plugin and the login page and reset password page was trashed. The site was not working and I fixed it using the above method.
I'm using this theme called IronBand.
It has a few custom post types, and one of them is called "Gig."
I created some custom posts under that Custom Post Type.
Then I wanted to changed the name of the Custom Post Type to "Show," so I fiddled with some php files.
Then it seemed like it was too complicated to change everything accordingly, so I replaced the php files I fiddled with to the original php files.
But now in the admin panel of "Gig," it says "No Gigs Found" Even if above the post list it says there are 17 published posts.
How could I make the published posts show up again?
Thanks!
The old slug will still be in the database, and that is what WP uses to find the custom post types. Have a look at the URL in admin. It would currently be:
/wp-admin/edit.php?post_type=show
As the old posts are still associated with the post type "gig", they will not be found in the Admin panel.
This happened to me recently, and I think I just went and changed the relevant values/slugs manually in the DB.