Created
July 1, 2014 13:21
-
-
Save remcotolsma/705c936d76dda6651580 to your computer and use it in GitHub Desktop.
Covert legacy Orbis activities to WordPress taxonomy terms.
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 | |
define( 'WP_USE_THEMES', false ); | |
require '../wp-load.php'; | |
global $wpdb; | |
$query = "SELECT * FROM $wpdb->orbis_activities;"; | |
$activities = $wpdb->get_results( $query ); | |
foreach( $activities as $activity ) { | |
$result = wp_insert_term( $activity->name, 'orbis_timesheets_activity' ); | |
if ( is_array( $result ) ) { | |
$term_id = $result['term_id']; | |
$rows_updated = $wpdb->update( | |
$wpdb->orbis_activities, | |
array( 'term_id' => $term_id ), | |
array( 'id' => $activity->id ), | |
array( 'term_id' => '%d' ), | |
array( 'id' => '%d' ) | |
); | |
echo $activity->id, ' - ', $activity->name, ' - ', $term_id, '<br />'; | |
} | |
} | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment