I rewrote the function from the link in your question to SQL.
Keep in mind that this script will also clear the page-templates assigned to the pages.
Make a backup of the wp_postmeta
table first.
DELETE pm
FROM wp_postmeta pm LEFT JOIN wp_posts p ON pm.post_id = p.id
WHERE
(p.post_type IN ('post', 'page') AND pm.meta_key <> '_thumbnail_id')
OR (p.post_type="attachment" AND pm.meta_key <> '_wp_attached_file'
AND pm.meta_key <> '_wp_attachment_metadata')
Related Posts:
- Delete all post meta except featured image
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- How to solve slow WordPress site caused by attachment_metadata
- Set Display Name to first and last name (phpmyadmin SQL Query)
- Size article thumbnails and retrieve them directly from database
- Emojis getting converted to “?”
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- WordPress database import: Row size too large
- Changing root password in PHPMyAdmin for WordPress Database when going live
- Can’t update WordFence Options, clear data manually
- Files on Localhost, Database on Server
- Installing local to live WP into subdirectory
- DB prefix not updating
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
- “BS_” rows in postmeta table
- Migrating meta_key and meta_value from old theme to new one
- mySQL database size large, but tables size less
- Missing latest posts and options after DB migration via phpMyAdmin
- Check if a database is well installed
- How do i get value from wp_postmeta?
- featured image not showing up with mysql_connect
- SQL query : Select a thumbnail for a media
- #1067 – Invalid default value for ‘post_date’ when trying to create a new column
- Deleting WordPress posts and media files based on author via MYSQL database
- Recovery – Restore Database after moving folder location locally
- Replacing javascript link in WordPress database without getting mysql syntax errors
- Set a cron job to delete a specific database table table every midnight
- How to edit custom table data in frontend
- local wordpress broke after changing URL
- I need to find posts that contain YouTube links without http:// or https:// prefix and add http:// to all of them
- how to access 2nd Mysqli Database from different server for wordpress
- Is there any defects for using same database prefix in WordPress for multiple sites?
- Deleted products from woocommerce are still in the database
- Error establishing a database connection – WordPress setup, everything else is working
- Store GravityForm data in phpmyadmin (mysql)
- How can I find user role in Mysql?
- How to import products in host instead of database on wordpress?
- What is recommended data type and encryption type for password in a database
- syntax error for changing user role from database
- I would like some help wth an SQL query to link posts with categories
- Where is the HTML-handler part in the wpdb class?
- Exporting Post ID, Post Title, Primary Category and Primary Category ID
- Featured image from custom to WordPress database
- WordPress Database Query works in phpMyAdmin but not in the code
- Duplicate database to roll back theme & content changes
- How to map data on CSV to web pages?
- WP website showing blank page after moving from subdomain to main domain
- How to create index (sql) to a meta_key?
- next comment id number wordpress
- Database structure for thousands of posts
- Search and Replace in Windows XAMPP site
- Delete all users meta that named: user_avatar
- WPCLI search and replace in a particlar site dir effect another site-dir
- How can i syn wordpress user table with a stand-alone php script?
- insert data from a form:: Warning Empty query mysqli::query()
- How can I get $wpdb to show MySQL warnings?
- Merging development site with live site
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- How to retrieve user data based on role using SQL?
- spambot registering without providing email or password, bypassing registration process
- After renaming MySQL database, I can no longer access my Blog page
- How To connect to the same WordPress database with different database user
- Possible to restore wordpress database from mysql56 and sqlite files?
- WordPress Database Posts Table query
- How much post meta data is too much?
- Hang Up Followed By Can’t select database
- WordPress character set issue
- How to extract some part of WordPress full source code
- Mysql Queries per Visit – Crazy High
- Store the wordpress “featured image” under »wp_posts« Database table
- Create a new table on the database and save parameters from a contact form
- Changed meta_key value in structures, now dashboard shows zero users
- live site do not update after importing sql database
- Why is converting my database to UTF-8 truncating entries?
- Widgets with *internal* links do not display after database migration
- using same mysql user with many databases
- Options table – where does my values go?
- Copy wp_postmeta from one database to another
- “MySQL server has gone away” since update to 3.8
- Why are my WordPress post queries so slow?
- Database question while Migrating from one domain to another on same WebHost [Bluehost]
- MySQL Database User: Which Privileges are needed?
- Import Excel (or csv) Table with user-data as subscribers to wordpress
- Print output of Table Creation
- Recommended Post Structure for DB Storage
- How to back-up a database on IIS
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- Export posts with postmeta without ID?
- export individual posts to text files or a single csv file
- Importing Concrete5 content to WordPress
- Custom wordpress SQL statement for a website
- why you don’t Implement PDO for access every thing to database
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- WordPress database connection failed, while mysql client is working [closed]
- How to find fresh (last modified) and sql backup?
- Uploading to WordPress Database
- Have WordPress Use a Different Database for users
- How to generate PDF dynamically based on values from the database in WordPress
- Understanding Redundant postmeta Tables in WordPress Database