-
-
Save blainerobison/f66a3e05e5400068d6f0 to your computer and use it in GitHub Desktop.
Import Categories and Tags Into WordPress Post. Plugin: WP All Import
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 | |
/** | |
* 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