Skip to content

Instantly share code, notes, and snippets.

View jared-rice's full-sized avatar
💻
Making rectangles

Jared Rice jared-rice

💻
Making rectangles
View GitHub Profile
@Soullighter
Soullighter / SQL
Last active March 8, 2024 13:27
How to delete all Media Files / Gallery from Database SQL in WordPress
Using FTP/SSH & Database
This method allows you to delete all items in your media library at once. Be sure to backup your database prior to doing this.
Each file in your media library has one row in the `wp_posts` table and two rows in the `wp_postmeta` table. Learn more about how WordPress stores media library entries in the database here. You can delete them all in bulk using these commands:
DELETE FROM `wp_posts` WHERE `post_type` = "attachment";
DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attached_file";
DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attachment_metadata";
@tjhole
tjhole / ACF: Random image from Gallery
Last active January 26, 2020 02:21
ACF: Random image from Gallery