Last active
January 9, 2020 15:25
-
-
Save mustardBees/dea6a11333ef3ec0a037e78dc9decb34 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 | |
/* | |
Plugin Name: Import terms | |
Plugin URI: https://www.philwylie.co.uk/ | |
Description: Given an array of terms, import into a specified taxonomy. Tool to help format array - https://link.from.pw/2tM8iEs | |
Version: 1.0.0 | |
Author: Phil Wylie | |
Author URI: https://www.philwylie.co.uk/ | |
License: GPL2 | |
*/ | |
function iweb_import_terms() { | |
if ( ! isset( $_GET['import-terms'] ) ) { | |
return; | |
} | |
$taxonomy = 'taxonomy'; | |
$terms = array( | |
'Term 1', | |
'Term 2', | |
); | |
foreach ( $terms as $term ) { | |
wp_insert_term( $term, $taxonomy ); | |
} | |
exit; | |
} | |
add_action( 'init', 'iweb_import_terms' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment