Created
January 30, 2016 05:17
-
-
Save Kudratullah/3d5b9819620b8bc199b2 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* This will copy all terms from country taxonomy to area taxonomy | |
* this will also include the child terms, but will not place them in right hierarchy | |
* for this please check the wp_insert_term() [ https://codex.wordpress.org/Function_Reference/wp_insert_term ] argument in codex and modify the loop | |
* @uses wp_insert_term() | |
* @return boolean | |
*/ | |
function CopyTermsToOtherTaxonomy(){ | |
static $done; | |
$fromTax = 'country'; | |
$toTax = 'area'; | |
if(!$done || $done == NULL){ | |
$args = array('orderby' => "id", 'hide_empty' => false); | |
$countries = get_terms($fromTax, $args); //get_terms( array('country'),$args); | |
//var_dump(count($countries)); exit; | |
foreach($countries as $country){ | |
wp_insert_term($country->name, $toTax, array('slug' => $country->slug)); | |
} | |
$done = true; | |
return $done; | |
} | |
} | |
add_action('init', 'get_tax_terms'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment