I would discourage using raw SQL for moving a post to a trash or back, especially since there’s a build in function for it:
wp_trash_post( $post_id );
More about the wp_trash_post() function.
The opposite is:
wp_untrash_post( $post_id );
wp_untrash_post()
also untrashes trashed comments.
In WP there are functions for many things – for instance you can trash/untrash only comments, leaving the post alone – in that case use: wp_untrash_post_comments()
and wp_trash_post_comments()
.
Related Posts:
- When trashing a post, also trash related comments
- Trash a post, send associated comments into the trash bin (change status)
- How to make comments work for a post loaded per Ajax?
- Allow variable amount of comments before pagination
- Export WordPress Posts and Meta Information in CSV format
- get comments and get posts in loop
- how to get permalink using sql
- How to display comments and comment form on custom post type?
- Update post date on every new comment?
- One comment per user email per post
- Can’t show comments count per post outside loop
- Only display posts with comments
- Restrict access to the Trash folder in Posts
- How to output comments number of a post per day?
- Hide comments awaiting moderation from user who submitted the comments
- Undelete post (untrash)?
- Use Cron to modify posts via sql
- Sql syntax error
- get posts and postmetas in assoc array
- Hide Post comments when displayed via WP_Query
- Including new Javascript only after a comment is made
- Disable Post/Page comment emails for creators
- Automatically generate Post/Page from searched Database item?
- Display posts with comments closed, with pagination?
- How to restore permanently trash page? [closed]
- Posts vs. Pages
- Get the most repeated post contents from a search?
- count the total number of comments the user has received for his published posts
- SQL query to retrieve all the records that have not indicated category
- How to Orderby Comments by post title?
- If modified on same day, show only time
- How to allow logged in users to post anonymously
- Email entire post contents
- Query get post,how to add comment box
- Update all comments time to random dates?
- How to verify wp user password by sql query in wp? [closed]
- Get ALL post ID’s export list (Only id’s. Php or sql not important )
- posts comments goes to trash
- Enable Comments Box On Custom Post Type
- Turn On Comments On Custom Post Types in Directory Theme
- Move comments only from one WP installation to another
- Second comments section for one post/page
- A friend wants to make a comment on one of my articles, she has to be logged to wordpress?
- Get all images in post and comments like Twitter before post title
- Showing author page if user has no post
- WordPress Comment posting problem
- What do comments with […] mean?
- What do these phpMyAdmin errors mean on my WordPress databaes?
- Internal post link creates comments on its own
- Show comment number per author per day
- Get all comments of author’s posts
- Remove Featured Image & All Media Uploaded to the Post
- Howto show comment count by post in post?
- Hide comments and posts posted by other user
- How to Assign / Move all Deleted post to a category
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- Display on page every post in blog WITH comments
- Can WordPress handle following functionalities?
- SQL Bulk Move old posts by one author to another category
- If post exists, make it a comment in existing post with same name?
- Export all posts to import as product items
- How to get post id of last approved comment?
- How can I get posts from 9/13/11 to today with SQL? [closed]
- Allow / show post comments in category pages
- Change published date and time using SQL query for page in every 5 hour
- how to show comments only author which send own posts in wordpress
- Merge get_comments & get_posts into a single query
- SQL DELETE multiple post_meta on single and multi-sites
- Bulk find & replace on WordPress posts/pages (minus image paths)
- SQL query: select duplicate posts – but using duplicate meta [duplicate]
- I want to change the WordPress comments file
- Adding wordpress posts using phpmyadmin
- How can i take all ids from untrash_post action?
- How to run select query of post with category and tags?
- Posting a comment redirects admin/users to blank page
- How to enable comments meta box for other author posts?
- Comments as part of a post
- Some comment box wordpress in 1 post [closed]
- Query to get data of a post, if in category?
- No comments on static front page
- Run Jquery Script after delete post in front end
- SQL query to remove first image in all posts
- Apply comment to different post (not the current post) [duplicate]
- How can I get a comment ID on Submit?
- External link not showing on post but showing on comment
- Delete junk text from all the post using my sql command
- Get first comment link on the post itself
- Get url/link to latest comments in a post
- Display only posts with comments
- wp_query select if have comments
- 2 tick boxes appearing below comments
- Admin moderates ALL comments (including post author)
- Show List of Posts With Comments Open
- If meta_key exists then don’t select this post?
- The page that displays Posts on homepage
- How can I show the positive and negative comments for a same post separately?
- How to update wp_posts with just the returned comment count from wp_comments (SQL GROUP BY)
- Undefined Function Fatal Error with Shortcode [closed]
- Best method for comment section associated with different images?
- Change permalinks in posts via SQL