• Resolved Once I Was A Developer

    (@i-was-a-developer)


    Hi,

    I have 3 blogs in my WPMU installation.

    It looks like only custom taxonomies created in the main blog are accepted by word press.

    If I try a wp_insert_term on a custom taxonomy in blog #2 created using the plugin in blog#2 I have an “invalid taxonomy” error.

    If I try a wp_insert_term on a custom taxonomy in blog #2 created using the plugin in blog #1 I have no error but no terms created in blog #2

Viewing 4 replies - 1 through 4 (of 4 total)
  • P.S. I’ve just downgraded to 2.2.6 and still same issue.

    So I’m guessing you don’t support WPMU?

    This is what I’ve done to make it work (dirty, but it works).

    Scenario:
    2 blogs, 2 languages en and es.

    Blog#1:
    custom post type: Product(products) with custom tax Product Category (product-category)
    Blog#2:
    custom post type: Producto(productos) with custom tax Categoria Producto(categoria-producto)

    wp_insert_term fails on Categoria Producto in Blog#2 (yes I switched using switch_to_blog).
    I created “Categoria Producto” in Blog#1 and that fixed the issue. Weird. At this point I start thinking it could be WP itself issue, since, at least from UI point of view, your plugin seems fine.

    Plugin Support Beda

    (@bedas)

    You can test if this is a WP Issue by registering some manual Taxonomies each blog and use your Code afterwards on those.

    On WordPress multisite the Types Plugin should work just fine.
    It needs to be active network wide or on each sub site.

    Since each site (blog) has it’s own database table set, and if you address that correctly, it should work flawlessly.

    Do manually registered Taxonomies work with your code on each site?

    Thanks Beda,

    I haven’t tried yet to register taxonomies manually. I’m going to do that and let you know what happens.

    Well it looks like it’s a WP issue.

    I installed a fresh WP and followed steps to enable multisite.

    I created 2 sites: the main one called “Site-1” (wp_site id=1) and a second one called “Site-2” (wp_site id=2).

    I manually created two custom taxonomies via a simple plugin:

    <?php
    
    /*
    Plugin Name: Test Custom Taxonomy WPMU
    
    */
    
    function registerTaxonomy() {
    
    	$blogId = get_current_blog_id();
    
    	$taxonomyName = "Custom Taxonomy $blogId";
    	$taxonomySlug = "custom-taxonomy-$blogId";
    
    	// create a new taxonomy
    	register_taxonomy(
    		$taxonomySlug,
    		'post',
    		array(
    			'label' => $taxonomyName,
    			'rewrite' => array( 'slug' => $taxonomySlug ),
    			
    		)
    	);
    }
    add_action( 'init', 'registerTaxonomy' );
    
    ?>

    and then created a script to test the term insert on customer taxonomy 2 on site 2:

    <?php
    
    #specify host or domain (needed for wp-includes/ms-settings.php:100)
    $_SERVER[ 'HTTP_HOST' ] = 'test.local';
    
    #location of wp-load.php so we have access to database and $wpdb object
    $wp_load_loc = "/var/www/test/wp-load.php";
    
    require_once($wp_load_loc);
    
    switch_to_blog(2);
    
    $o = wp_insert_term( "Test for CT 2", 'custom-taxonomy-2');
    
    print_r($o);
    
    ?>

    and still getting error.

    Moreover if I do a term insert on customer taxonomy 1 – that is NOT defined in site2 – i can see that site2 db has the entry in the wp_2_term_taxonomy, and that does not make sense.

    I guess I will open the bug somewhere for WP dev community, unless I’m missing something since I’m not so into WP dev & logic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WPMU Custom Taxonomy Issue’ is closed to new replies.