Control whether or not to trash a custom post type

Hook onto trashed_post and use wp_untrash_post() to reverse upon meeting a condition, pseudocode example… add_action(‘trashed_post’, ‘wpse_218031_trashed_post’); function wpse_218031_trashed_post($post_id){ //use post_id to check conditions… if not met call: if ( $some_condition ) { wp_untrash_post($post_id); } } trashed_post runs after wp_trash_post and after the post is moved to trash. By the way, if the constant EMPTY_TRASH_DAYS is … Read more

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

Just as @cybmeta mentioned, the info is stored in the post meta table. When we trash a post then the post meta key _wp_trash_meta_status is added with the value of the previous post status (publish, pending, draft, … ). Within the wp_trash_post() function, we have: add_post_meta($post_id,’_wp_trash_meta_status’, $post[‘post_status’]); add_post_meta($post_id,’_wp_trash_meta_time’, time()); We might therefore try: // Get … Read more

How to restore permanently trash page? [closed]

The only way to restore it is to restore a backup of your MySql database. Login to your web host and see if there are any backups of your database available. Then you can restore the backup and it will bring that content back. Make sure you haven’t added any other content after the backup … Read more

Restore trashed posts with comments

Once you restore the posts that are trashed you can try running the comment-fix.php script to reset the comments to appear and show the correct count. If it has been over thirty days in the trash the comments are gone for good, sorry.

wp_trash_post not firing

There are two hooks you should be considering– wp_trash_post and trashed_post. Based on your statement that you want this to work “when a post is placed into the trash” I’d suggest the latter is the better hook, since it runs after the post is successfully placed in the trash. I hate to suggest this as … Read more

Why trash folder got empty automatically?

Check the value for the constant EMPTY_TRASH_DAYS. With this constant can you control how long is the time to save in trash before delete automatically. Check at first the wp-config.php for this constant, maybe is set in your installation for a small value. The codex write more about the constant and his possibilities. Also it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)