Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Last active January 9, 2020 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustardBees/dea6a11333ef3ec0a037e78dc9decb34 to your computer and use it in GitHub Desktop.
Save mustardBees/dea6a11333ef3ec0a037e78dc9decb34 to your computer and use it in GitHub Desktop.
<?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