Skip to content

Instantly share code, notes, and snippets.

@ashfame
Created January 24, 2012 08:00
Show Gist options
  • Save ashfame/1668764 to your computer and use it in GitHub Desktop.
Save ashfame/1668764 to your computer and use it in GitHub Desktop.
Changing postmeta fields programmatically
<pre><?php
require 'wp-load.php';
$postmeta_field_name = 'video_url'; // fill it
echo $query = "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '$postmeta_field_name';";
$data = $wpdb->get_results( $query );
print_r( $data );
foreach ( $data as $row ) {
$row['meta_value'] = new_url_api( $row['meta_value'] );
// update query here
}
@ashfame
Copy link
Author

ashfame commented Jan 24, 2012

This file goes into the root of a WP install, and then ran by accessing the file through a browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment