Skip to content

Instantly share code, notes, and snippets.

@blainerobison
Last active August 29, 2015 14:26
Show Gist options
  • Save blainerobison/f66a3e05e5400068d6f0 to your computer and use it in GitHub Desktop.
Save blainerobison/f66a3e05e5400068d6f0 to your computer and use it in GitHub Desktop.
Import Categories and Tags Into WordPress Post. Plugin: WP All Import
<?php
/**
* Import Categories and Tags Into Post
*
* Using WP CSV to export blog posts, taxonomy fields include slug (e.g. term:Term, another-term:Another Term)
* This will exclude slug, returning only term's name
*
* Example Usage: [prefix_import_term_name({tx_category[1]})]
* [prefix_import_term_name({tx_post_tag[1]})]
*
* Plugin: WP ALL Import
* Reference: http://www.wpallimport.com/documentation/developers/execute-php/
*/
function prefix_import_term_name( $input ) {
$clean = array();
$parts = explode( ",", $input );
foreach( $parts as $item ) :
$pieces = explode( ":", $item );
$clean[] = end( $pieces );
endforeach;
return implode( ",", $clean );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment