Created
August 15, 2017 01:01
-
-
Save lgedeon/8b3fe5d4090afd9f502fb30a82026f87 to your computer and use it in GitHub Desktop.
Delete all post_meta.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Meta_Reset { | |
function __construct() { | |
add_action( 'parse_request', [ $this, 'parse_request' ] ); | |
} | |
/** | |
* Usage: mydomain.com/?meta_reset=1 | |
*/ | |
function parse_request() { | |
global $wpdb; | |
$table = _get_meta_table( 'post' ); | |
$meta_keys = [ | |
'_my_meta_key', | |
]; | |
if ( isset( $_GET[ 'meta_reset' ] ) ) { | |
foreach ( $meta_keys as $meta_key ) { | |
$query = "DELETE FROM $table WHERE meta_key = '$meta_key'"; | |
$wpdb->query( $query ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment