Restore trashed posts with comments

When a WordPress post is trashed, all the comments are trashed as well. I would expect the “undo” button to restore both the post and the comments. However, all the comments seem to just disappear : they’re not moved into the Dashboard->Comments->Trashed folder, and they are not restored with the original post. Is there a … Read more

wp_trash_post not firing

I want to call a function when a post is placed into the trash. I want to do something more complicated than the following, but have simplified to what’s below just to see if it’ll work and it doesn’t. function gna_my_function() { echo ‘trashed ‘; } add_action(‘wp_trash_post’, ‘gna_my_function’); Thanks 1 Answer 1 There are two … Read more

Why trash folder got empty automatically?

Yesterday I move some of my WordPress product to trash, and keep only 4 products available. Today I open my site, all trash products was not there? But the 4 products still there. I don’t know are them deleted automatically? What happen, please advice me? 1 Answer 1 Check the value for the constant EMPTY_TRASH_DAYS. … Read more

Custom Role can’t trash Custom Post Type

I have a post type that I set up some capabilities for and I attached them to a new Role, however, the role can not trash them. I’m not sure why though. Here is the portion of my array for the capabilities. ‘capabilities’ => array( ‘publish_posts’ => ‘publish_mro_project’ ,’edit_posts’ => ‘edit_mro_project’ ,’edit_others_posts’ => ‘edit_others_mro_projects’ ,’delete_posts’ … Read more

Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?

I’m currently working on developing a plugin with a custom post type of “Dealer Location”. (Not relevant to question, just a bit of background) When a post is in the trash and “delete permanently” is pressed, I need to remove this piece of meta from each user. When a post/posts are in the trash and … Read more

Dynamically create/remove terms in taxonomy when custom post type is published/trashed

Am struggling a bit with creating & removing terms based on when a custom post type is published and trashed. Ideally, I would like to create a new term in my custom taxonomy when a custom post type is published. Then, when that post in the custom post type is trashed, I need to check … Read more

Add frontend “Restore” link

I am using get_delete_posts_link($postid) to let users send their posts to the trash from the frontend. Now I’m trying to replicate the same functionality for them to “untrash” or restore the posts as well. get_delete_posts_link($postid) seems to generate a URL like this: http://mysite.com/wordpress/wp-admin/post.php?post=555&action=trash&_wpnonce=0d6fc30f3b And when I go to wp-admin and look at what link the … Read more