If you need an SQL query, then this option should be suitable
function src_flush_revisions () {
global $wpdb;
$post_id = 5//exp post id
if ( isset( $timeLimit ) ) {
$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT `ID` FROM $wpdb->posts WHERE `post_type` = 'revision' AND `post_parent` = %d", $post_id ) );
foreach ( $revision_ids as $revision_id ) {
wp_delete_post_revision( $revision_id );
}
}
}
add_action( 'admin_init', 'src_flush_revisions' );
Related Posts:
- Manually removing revision post types
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- Delete all drafts?
- Why my wp_posts data is so huge?
- How Can I Always Display A Particular Post First Using WP_Query?
- Clean up customize_changeset in DB
- Change permalinks in posts via SQL
- Where is the old post permalink slug stored?
- How to Group Posts by the First Letter or Number?
- How are terms connected with posts in database?
- Moving WordPress to new server: no posts found
- how to enable different number of revisions for different blogs when using WPMU?
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- How can I display a specific user’s first published post?
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- wp_enqueue_media() slows down my WP site
- How can I get all posts data from within a paginated search result?
- Query posts from different categories in multisite
- posts_per_page doesnt work
- Sorting posts according to view counts not working
- Are posts updated or built from revisions + autosaves?
- Only display posts after current date
- How much of my site can I recover from public_html?
- Reset/Reorder posts ID in the MySQL wp_posts table
- Improving WP_Query for performance when random posts are ordered
- Get posts by name and taxonomy term
- WP_Query Authors OR Categories
- How to delete all the content of a wordpress site without deleting the Post and pages?
- do_shortcode within post query
- Extracting post categories
- Most liked page not displaying posts
- Query get post,how to add comment box
- How to hide html tags on revision comparison pages?
- get query() without post content?
- How can I setup a relationship using categories in WordPress?
- posts_per_page option limits the number of Gallery items
- How i can limit period of post publication?
- When open add new post or page WordPress add post with ID=0 continuously [closed]
- Anyone know why wordpress converts some html entities to their numeric equivalents?
- What do these phpMyAdmin errors mean on my WordPress databaes?
- Exclude current custom post on single post
- Dynamically switch template on click
- Get all custom post types excepted some…
- Get all comments of author’s posts
- Display post changelog in post
- First x post with another template then the others
- Why Query is returning empty array?
- Wrap every month posts in div
- Get posts and include taxonomy term
- meta_value timestamp older than now
- Do not show children of a category
- post__in not working with pre_get_posts, but post__not_in does work
- Add field to user meta table in database when link is clicked
- Query for first 3 posts to change the look and feel
- Query posts and filter at query time by value of custom meta
- Very complex post query
- wp_posts table extremely large
- Display post by click on the link
- Queries take 120+ seconds on my large WordPress site
- WordPress loop not working on static front page
- How to display only one category in a custom post type?
- Import custom database into wp and keep the post id
- why the posts queried from sql is more than those showed on the page?
- Moved to a new server, backup was a day old and missing 3 posts, anyway to recover them from old host?
- Anyone know a php snippet for showing the first 200 characters of the most recent post?
- Get current taxonomy and display query accordingly
- Is there a function to get post info for any publish_status by post ID?
- Your ideas on my though “delete or move all of the posts in a specific category when 3 days are passed”
- How can I globally italicize list of texts in the UI database or Posts? [closed]
- Check if almost 10 year old – working code is up to date
- Query to fetch custom taxonomy along with post title
- How to fetch courses in all languages in WordPress?
- Query custom post type custom meta key
- Bulk find & replace on WordPress posts/pages (minus image paths)
- filter posts based on menu_order
- Show 5 posts and than 3 posts offset with pagination
- I need some explanation on global $post [duplicate]
- how i show manual data in a post
- How to delete all posts with dead image urls?
- Querying posts from current category, using a variable as array argument
- Maximum number of posts per page before affecting performance?
- Query posts from newest category
- Surrogate ID for posts, is there an alternative field in the posts table?
- wp query custom orderby not custom field
- Query post by meta key of another table
- Expired Post with More Recent Time Stamp?
- Query post category & remove any post id
- Converting Posts to Pages
- Ordering posts alphabetically by meta keys and title
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- How to change the publishing date of each posts?
- Grab next post title in archive page
- Continuous listing from a custom field
- How to store post rating system data post independent?
- How to limit post query to only return a total count of items with certain post statuses?
- Load posts from external source if not found in database
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- Display posts with id equal to relationship value
- Sort Posts Alphabetically Based on Specific Category (Divi)