Questions tagged [trash]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
97 views

How to prevent users from permanently deleting a post from trash, but allow them to restore it?

for security reasons I need to: prevent all users except admins from permanently deleting posts from trash. They should still be able to trash drafts, and be able to restore drafts from trash. The ...
user232080's user avatar
1 vote
0 answers
67 views

wp_trash_post not firing as expected (also applies to trashed_post)

This is similar to wp_trash_post not firing but follows on from there. I have a piece of code to run on this hook; function to_fire_on_hook($post_id) { ... do stuff // Get the slug of the $post_id ...
Chris Pink's user avatar
0 votes
0 answers
25 views

is possible to interupt a post deletion when empty the trash

it is possible once called a before_delete_post action not to allow WP to delete post on certain condition? something like e this: add_action( 'before_delete_post', 'my_custom_delete', 10); function ...
Totoro3D's user avatar
0 votes
1 answer
323 views

Get rid of "trash can" for custom post type

I have a CPT "foo". I want to totally disable the "trash can" feature, so that any time on the the CPTs is deleted, it is simply permanently removed. Not put in the trash can. How ...
John Dee's user avatar
  • 503
0 votes
1 answer
155 views

How can I specify the post status of an untrashed post?

By default Wordpress assigns the draft status to a post that has been untrashed. I would like to assign the pending status to posts that are untrashed. This seems to be possible with ...
mike23's user avatar
  • 5,961
0 votes
1 answer
748 views

Cancelled orders move to Trash automatically in Woocommerce - how to disable?

I have a Wordpress 5.4.1. website, with Woocommerce 4.1.1. installed. It seems that orders which have the status "Cancelled" move to Trash automatically after one month passes (from the order date). ...
K. Golov's user avatar
1 vote
0 answers
248 views

How can Reusable Blocks be fully deleted?

All of the reusable blocks on one of my sites were deleted last week. Not just deleted, but the trash emptied. I've already had a security vendor audit the site, and they concluded there was no hack, ...
WebElaine's user avatar
  • 9,310
1 vote
1 answer
2k views

Shortcode to delete post from front end

I'm trying to create a short code to delete post that user publish from the front end of my site. I've tried the short-code below but I keep getting the error "The link you followed has expired." ...
Kendell Daniel's user avatar
2 votes
1 answer
348 views

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 ...
Syd McArdle's user avatar
0 votes
1 answer
2k views

Remove Featured Image & All Media Uploaded to the Post

I found a solution of removing featured image related to the post when delete the post from this article but, I want to remove all the uploaded media also with post removing. Delete all WP image ...
Mohsin Alam's user avatar
0 votes
1 answer
44 views

Restore page after deleting it from trash

I accidentally deleted a page in my trash area, is there a way I can restore it? I can no longer find the page.
Makala's user avatar
  • 1
0 votes
0 answers
194 views

Bulk trashing post 'fails'

I want to bulk delete child posts of a custom post type, and I've made it work. I'm in class context: // In a register method which registers all hooks. add_action( 'wp_trash_post', [ $this, '...
dingo_d's user avatar
  • 1,939
1 vote
0 answers
238 views

posts comments goes to trash

My website was working fine until today, I just discovered that all comments made goes straight to trash. I did not install new plugins, I don't have akismet. It just started. I have deactivated all ...
Atoms's user avatar
  • 41
5 votes
2 answers
3k views

wp_delete_post() deletes post instead of moving it to trash

I have set up a custom post type, which user can edit from the frontend. I'm using wp_delete_post() to allow users to delete a post they created. It works, but the posts get deleted instead of being ...
Ilona's user avatar
  • 125
4 votes
1 answer
295 views

Does WP fire delete_post when trashed posts are automatically deleted?

I have a custom db table that stores additional post data and I need to delete posts from my custom table when the original post is deleted. Will WP fire the delete_post action below and run ...
zcleft's user avatar
  • 61
2 votes
1 answer
1k views

get_post() function returns post even if it is trashed

I'm developing a WordPress theme. I am selecting one post as a 'featured post' from the customizer settings. I want to display this post differently on home page. I'm using following code to get the ...
Nilesh G's user avatar
  • 182
5 votes
1 answer
6k views

Remove Trash / Delete option for Custom Post Type / Taxonomy

I've created a custom post type prj, and I need to disable move to trash option by any user role! Same goes with a taxonomy org associated with the same post type. Here is the code I've come up with ...
Hassan Alvi's user avatar
0 votes
1 answer
222 views

Script doesn't trash custom post types. Instead it duplicates the post and generate new versions in the trash

I've a function which deletes custom post types after a specific time. In my case after 30 days. The problem is, that the posts are not trashed. Instead WordPress creates a new version of the post ...
Cray's user avatar
  • 145
0 votes
0 answers
44 views

WordPress deletes custom posts instead of trash them

I need to trash some custom posts, under certain conditions, via code (it's a plugin self-written) The theme used is a children I don't shutdown the ability to trash the post; In config.php there ...
sineverba's user avatar
  • 141
2 votes
1 answer
902 views

Error after deleting Custom Post Type with a function (no trash used)

I'm using a function which I built to delete all posts from a user after a specific post is deleted. In my case I'm using a Custom Post Type called company. And additional Custom Post Types like jobs ...
Cray's user avatar
  • 145
0 votes
1 answer
198 views

How can i take all ids from untrash_post action?

When the user chooses to restore a post ( from "Trash" folder ) with the following way, through the action untrash_post, i get the id of the posts. function my_untrash_post_type( $post_id ) { ...
Shake-the-World's user avatar
0 votes
2 answers
8k views

How to recover permanently deleted blog posts?

I accidentally deleted about 20 blog posts and they were in my trash folder for over a month and now have permanently deleted. I was wondering if there's a way to recover these? For example I have ...
Hattie Rowan's user avatar
0 votes
2 answers
391 views

SQL Command for restoring trashed comments

When trashing a post, also trash related comments so here is what i want, what‘s’ the sql Command I want to move some post to trash according their ID, what is the sql command,I can restore these ...
Furukawa Tomo's user avatar
0 votes
1 answer
572 views

wp_trash_post hook - problem with page updating if using wp_die

I am building a plugin which in some cases prevents certain posts from being put into the bin. For this, I am using "wp_trash_post". In the callback function, I do the logic to check if the post can ...
thairish's user avatar
  • 213
2 votes
1 answer
3k views

Can a user with admin role get 'Sorry, you are not allowed to move this item to the Trash' error when trashing a post?

I got the wp_die error message: Sorry, you are not allowed to move this item to the Trash. on trying to put the post in trash, but when I tried to put it in trash again the wp_die error message: ...
IAmDhar's user avatar
  • 96
2 votes
1 answer
422 views

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 ...
adel's user avatar
  • 31
1 vote
1 answer
10k views

How to restore permanently trash page? [closed]

I have accidentally permanently deleted the home page from my website. Is there any way how to restore it? :( Thank you in advance.
Tomas Molnar's user avatar
0 votes
1 answer
72 views

Trash in WP 3.8?

For some reason the trash link (to see the trashed posts) is missing, but I'm not sure if it's even supposed to be there in version 3.8.1 We do have the choice to trash an item But I can't see where ...
Robert Sinclair's user avatar
1 vote
1 answer
801 views

How to untrash a post only if it was not a draft?

I know I can do wp_untrash_post( $post_id ); And check the post status with $post_status = get_post_status ( $post_id ) I'm in a situation where I must untrash some posts but only if the post ...
realtebo's user avatar
  • 257
2 votes
2 answers
2k views

Exclude trash from save_post

I have a function which processes custom metabox data on saving my custom post type: add_action('save_post_customtypehere','myown_save_customtype_fn'); function myown_save_customtype_fn($ID) { ... } ...
Adam's user avatar
  • 23
2 votes
1 answer
317 views

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 : ...
bernihl's user avatar
  • 21
2 votes
1 answer
176 views

How to add a column to the Trash page?

I'm trying to add a column to the trash page for posts and pages but can't find a way to hook into that specific area. I've been able to use functions like manage_posts_columns and ...
j08691's user avatar
  • 765
1 vote
2 answers
3k views

custom post type, hide or disable the trash button in publish meta box

I have been adding a post type to my theme, how do I hide/disable the Move to trash button? Here is my code so far: $labels = array( 'name' => _x( 'Inhoud', 'taxonomy ...
poashoas's user avatar
  • 125
4 votes
3 answers
2k views

Trash bin for categories

Today I accidently happend to delete my category right after I've noticed there is no trash in categories. I wonder is there any way to include trash bin for it? I've made a little research over a ...
Mateusz Winnicki's user avatar
1 vote
1 answer
862 views

How to cancel the trash action inside wp_trash_post

I need to restrict the button "EMPTY TRASH" and make it delete only the posts only if the logged in user is the creator. I tried to use the wp_trash_post and i need to decide in the function if i ...
e4rthdog's user avatar
  • 441
0 votes
2 answers
797 views

How to cancel an action hooked to untrash_post? or any hook

I want to do the following in a plugin: - hook to untrash_postwith a custom function - do some checking inside custom function - cancel actual post restoring (untrashing) I've tried with ...
SXN's user avatar
  • 1
0 votes
1 answer
2k views

Wordpress has a trash for users? (Wrong result for count_user, greater than expected)

I am using count_users() function to count users on my wordpress sites. In my administration area -> 'Users' I can see 7 users, but the function returns 9. After some time, searching for errors in my ...
Sasha Grievus's user avatar
1 vote
1 answer
776 views

Control whether or not to trash a custom post type

I need to have control over the trash / delete action on a custom post type. I need to check for some conditions and decide if i should trash the CPT or not. The wp_trash_action hook that is fired ...
e4rthdog's user avatar
  • 441
2 votes
1 answer
4k views

How can I hook into existing WordPress Bulk actions?

I am creating a plugin which syncs both standard WP data and custom fields within a custom meta box on post edit pages, to an external resource using SQL queries. However my functions are currently ...
T Andrew's user avatar
0 votes
1 answer
1k views

How to change 'Move to Trash' to 'Move to Draft' for my blog's users?

I want that only Admin and Editor roles can use the 'Move to Trash' option in my blog, and other users will get the 'Move to Draft' option instead. Like inside of the 'Quick Edit' / 'Bulk Actions' ...
Muklesur Rahaman's user avatar
0 votes
1 answer
713 views

Nonce for Trashing Item

I have a custom admin page. On it, I have created a filtered list of the custom post type based on postmeta data. I have to create a link to delete that post. I am trying to figure out how to ...
DeltaTango's user avatar
1 vote
1 answer
480 views

How can I trash multiple posts at once from the front end?

I took a peek at the code in edit.php and am now generating links with this code: wp_nonce_url("/wp-admin/edit.php?doaction=trash&post_type=post&ids=postIds", "bulk-posts") The ...
Florian's user avatar
  • 1,575
0 votes
1 answer
61 views

Post deleted in trash [closed]

I need a plugin or some method to recover deleted post of trash.
Fran Amaterasu's user avatar
3 votes
3 answers
2k views

Undelete post (untrash)?

Which function should be used to move post from trash to published pages? i.e. is there wp_undelete_post or something like?
T.Todua's user avatar
  • 5,709
1 vote
0 answers
102 views

Sort trash by date post was trashed

Is it possible to sort the trash for post by the last post added to trash. EG: I trash post 4,2,1,3,5 I would like these post to be sorted in trash by the last post trashed, so they would appear in ...
DarrenLee's user avatar
1 vote
1 answer
2k views

Missing 'Move to Trash' option from bulk select box

I seem to be missing the bulk select option for moving multiple items to the trash. This happens when all plugins are deactivated as well. Has anyone come across this before? https://i.stack.imgur....
Dan's user avatar
  • 13
0 votes
2 answers
2k views

Changing a post status name

How do I change the status name "Trash" to "Archive". I don't want to change the functionality of the status or make a new status. I have tried Edit Flow custom status but I get some conflicts with ...
user1721230's user avatar
0 votes
1 answer
1k views

How to retrieve the date on which a post was moved to trash?

I need to retrieve a list of posts that are in trash based on the date on which they were trashed. The following code allows me to retrieve posts that are in trash, but how to filter them by date? ...
Sudar's user avatar
  • 799
0 votes
1 answer
393 views

wp.getPosts with status = 'trash' using node.js

I was wondering how to set the filter option for wp.getPosts. I want to get posts with a status of 'trash'. filter is currently blank, and returns all posts other than trash. I am using the xmlrpc ...
kkimble006's user avatar
0 votes
1 answer
2k views

Restrict access to trash, only admin

I'm new in WordPress. I have to restrict access to the Trash for all users except the administrator. All users CAN move to the Trash, but only admin can delete permanently or restored. I do not know ...
zetka91's user avatar