WordPress.org

Ready to get started?Download WordPress

Forums

CSV Importer
[resolved] Custom Taxonomies Import not working (19 posts)

  1. Ian
    Member
    Posted 3 years ago #

    For some reason, I can't seem to get posts to upload with custom taxonomies intact.

    I get the errors:
    Unknown taxonomy (Edition)

    Unknown taxonomy (Creator)

    Unknown taxonomy (Series/Event)

    The taxonomies work fine throughout the rest of the site, and everything else imports perfectly, including custom post types, custom fields, etc.

    This is the code I'm using to do the post types in the functions:

    add_action( 'init', 'create_my_taxonomies', 0 );
    
    function create_my_taxonomies() {
    
    register_taxonomy( 'creator', 'post', array( 'hierarchical' => false, 'label' => 'Creator', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'edition', 'post', array( 'hierarchical' => false, 'label' => 'Edition', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'series', 'post', array( 'hierarchical' => false, 'label' => 'Series/Event', 'query_var' => true, 'rewrite' => true ) );
    
    register_taxonomy( 'dc-series', 'DC', array( 'hierarchical' => false, 'label' => 'DC Series/Event', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'wildstorm-series', 'Wildstorm', array( 'hierarchical' => false, 'label' => 'Wildstorm Series/Event', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'marvel-series', 'Marvel', array( 'hierarchical' => false, 'label' => 'Marvel Series/Event', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'image-series', 'Image', array( 'hierarchical' => false, 'label' => 'Image Series/Event', 'query_var' => true, 'rewrite' => true ) );
    
    register_taxonomy( 'dc-character', 'DC', array( 'hierarchical' => false, 'label' => 'DC Comics Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'wildstorm-character', 'Wildstorm', array( 'hierarchical' => false, 'label' => 'Wildstorm Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'marvel-character', 'Marvel', array( 'hierarchical' => false, 'label' => 'Marvel Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'ultimate-marvel-character', 'Ultimate-Marvel', array( 'hierarchical' => false, 'label' => 'Ultimate Marvel Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'image-character', 'Image', array( 'hierarchical' => false, 'label' => 'Image Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'buffyverse-character', 'Buffyverse', array( 'hierarchical' => false, 'label' => 'Buffyverse Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'hellboy-character', 'Hellboy-Universe', array( 'hierarchical' => false, 'label' => 'Hellboy Universe Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'americas-best-character', 'Americas-Best', array( 'hierarchical' => false, 'label' => 'Americas Best Comics Character', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'fables-character', 'Fables', array( 'hierarchical' => false, 'label' => 'Fables Character', 'query_var' => true, 'rewrite' => true ) );
    }

    It all seems right to me, but maybe I'm missing something stupid?

    http://wordpress.org/extend/plugins/csv-importer/

  2. Ian
    Member
    Posted 3 years ago #

    it also doesn't work for just using the slugs, which I tried first:

    Unknown taxonomy (edition)

    Unknown taxonomy (creator)

    Unknown taxonomy (series)

  3. dvkob
    Member
    Plugin Author

    Posted 3 years ago #

    ianaleksander: May I see the file you're trying to import?

  4. Ian
    Member
    Posted 3 years ago #

  5. dvkob
    Member
    Plugin Author

    Posted 3 years ago #

    ianaleksander: Works for me. Below is the code I used in my functions.php. It just adds register_post_type stuff to your code.

    add_action( 'init', 'create_my_taxonomies', 0 );
    
    function create_my_taxonomies() {
        register_post_type('DC', array('public' => true, 'label' => 'DC'));
        register_post_type('Marvel', array('public' => true, 'label' => 'Marvel'));
        register_post_type('Image', array('public' => true, 'label' => 'Image'));
        register_post_type('Wildstorm', array('public' => true, 'label' => 'Wildstorm'));
        register_post_type('Ultimate-Marvel', array('public' => true, 'label' => 'Ultimate-Marvel'));
        register_post_type('Buffyverse', array('public' => true, 'label' => 'Buffyverse'));
        register_post_type('Hellboy-Universe', array('public' => true, 'label' => 'Hellboy-Universe'));
        register_post_type('Americas-Best', array('public' => true, 'label' => 'Americas-Best'));
        register_post_type('Fables', array('public' => true, 'label' => 'Fables'));
    
        register_taxonomy( 'creator', 'post', array( 'hierarchical' => false, 'label' => 'Creator', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'edition', 'post', array( 'hierarchical' => false, 'label' => 'Edition', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'series', 'post', array( 'hierarchical' => false, 'label' => 'Series/Event', 'query_var' => true, 'rewrite' => true ) );
    
        register_taxonomy( 'dc-series', 'DC', array( 'hierarchical' => false, 'label' => 'DC Series/Event', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'wildstorm-series', 'Wildstorm', array( 'hierarchical' => false, 'label' => 'Wildstorm Series/Event', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'marvel-series', 'Marvel', array( 'hierarchical' => false, 'label' => 'Marvel Series/Event', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'image-series', 'Image', array( 'hierarchical' => false, 'label' => 'Image Series/Event', 'query_var' => true, 'rewrite' => true ) );
    
        register_taxonomy( 'dc-character', 'DC', array( 'hierarchical' => false, 'label' => 'DC Comics Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'wildstorm-character', 'Wildstorm', array( 'hierarchical' => false, 'label' => 'Wildstorm Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'marvel-character', 'Marvel', array( 'hierarchical' => false, 'label' => 'Marvel Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'ultimate-marvel-character', 'Ultimate-Marvel', array( 'hierarchical' => false, 'label' => 'Ultimate Marvel Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'image-character', 'Image', array( 'hierarchical' => false, 'label' => 'Image Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'buffyverse-character', 'Buffyverse', array( 'hierarchical' => false, 'label' => 'Buffyverse Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'hellboy-character', 'Hellboy-Universe', array( 'hierarchical' => false, 'label' => 'Hellboy Universe Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'americas-best-character', 'Americas-Best', array( 'hierarchical' => false, 'label' => 'Americas Best Comics Character', 'query_var' => true, 'rewrite' => true ) );
        register_taxonomy( 'fables-character', 'Fables', array( 'hierarchical' => false, 'label' => 'Fables Character', 'query_var' => true, 'rewrite' => true ) );
    }

    I don't see any taxonomy fields in your file, though.

  6. Ian
    Member
    Posted 3 years ago #

    oh sorry, I totally posted the wrong one. that one has the taxonomy stuff trimmed since it wasn't working.

    http://www.tradereadingorder.com/temp/test.csv

    here's the file with the taxonomies. Just tested it, and edition, creator, and series give the error.

    thanks so much for your help, by the way!

  7. headway
    Member
    Posted 3 years ago #

    Any resolution to this? I'm having a similar issue, can't get data into a custom taxonomy.

  8. headway
    Member
    Posted 3 years ago #

    @ianaleksander - While trying to fix my issue I think I found your problem. The column header you have declared for your hierarchical custom taxonomy is csv_ctax_(edition). Simply remove the parenthesis. The header should look like this csv_ctax_edition.

    Hope this helps with your errors.

  9. Ian
    Member
    Posted 3 years ago #

    Oh wow, that is such an amazingly simple solution. If this works, you've pretty much saved my life.

  10. Ian
    Member
    Posted 3 years ago #

    Oh it totally worked! Thank you so much. Absolutely awesome.

  11. dvkob
    Member
    Plugin Author

    Posted 3 years ago #

    headway: ianaleksander: Glad you worked it out. It's nice to see people in the community helping each other out. Taxonomy syntax is a bit tricky, but I don't think there's an easier way to use custom taxonomies from a CSV file.

  12. Ian
    Member
    Posted 3 years ago #

    It's been really great since then - this whole plugin has been a godsend. Absolutely essential to my workflow right now.

  13. luisrivera
    Member
    Posted 3 years ago #

    hi guy's
    Im having the same trouble but its not working for me.

    I read in another post that CSV Importer doesnt work with Custom Taxonomies if they are Herarchical.

    Is it true?
    Because what i did is

    add_action('init', 'create_producto');
    	function create_producto() {
        	$producto_args = array(
            	'label' => __('Producto'),
            	'singular_label' => __('Producto'),
            	'public' => true,
            	'show_ui' => true,
            	'capability_type' => 'post',
            	'hierarchical' => false,
            	'rewrite' => true,
            	'supports' => array('title', 'editor', 'thumbnail')
            );
        	register_post_type('producto',$producto_args);
    	}

    and

    register_taxonomy("catalog", array("producto"), array("hierarchical" => true, "label" => "Catalogs", "singular_label" => "Catalog", "rewrite" => true));

    and my .csv file goes like this

    csv_post_title,csv_post_post,csv_post_typ,csv_ctax_catalog

    If that is the case and is not that im doing something wrong... can somebody let me know if there is another CSV Import Plugin around that works better?

    Thx everybody

  14. luisrivera
    Member
    Posted 3 years ago #

  15. knokenet
    Member
    Posted 3 years ago #

    Hi,

    I'm struggling with a taxonomy import problem.
    All works well with posts, categories, tags etc, even taxonomy tags are working (created and inserted).
    But with taxonomy categories I have a problem: categories are being created but not chosen for the post. Why?

    Anyone?

    Thanks,

    Knokenet

  16. dvkob
    Member
    Plugin Author

    Posted 3 years ago #

    knokenet: Are you sure that the categories are not chosen for the post? By default, WordPress displays hierarchical categories a post belongs to somewhat unintuitively. There might have been a related topic on the forums in the past...

  17. knokenet
    Member
    Posted 3 years ago #

    Quite sure...tried endless variations...
    I'll search a bit more...thanks...

  18. stevecoy
    Member
    Posted 3 years ago #

    A super easy way to get around the hierarchical taxonomy issue when importing is to simply register your taxonomies as non-hierarchical, then import your CSV, then in your code for registering your taxonomies, add the 'hierarchical' => true parameter back in.

  19. tzeldin88
    Member
    Posted 3 years ago #

    @stevecoy -- Thanks! I was struggling with how to import MULTIPLE values to a Hierarchical custom taxonomy. This is a bit of a workaround, but it definitely worked.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic