And you’re using the same theme on the child blog?
have you tried registering the custom posts stuff in mu-plugins instead of the theme functions file?
You might need to set the capabilities arg, it defaults to none.
I see you set capability_type. I don’t see that in the arguments. I see capability, and the options are manage_terms, edit_terms, delete_terms, or assign_terms.
Strictly guessing here.
@andrea_r – yes, i’m using the same theme in both the main blog and the child blog.
@miklb – good guess, but i tried a variety of different capabilities settings (I am passing in an array according to the codex, right?) but to no avail. Variations included:
register_taxonomy("Product Categories", array("campaign"), array("hierarchical" => true, "label" => "Product Categories", "singular_label" => "Product Category", "capabilities" => array('manage_terms'), "rewrite" => array( 'slug' => 'product' )));
register_taxonomy("Product Categories", array("campaign"), array("hierarchical" => true, "label" => "Product Categories", "singular_label" => "Product Category", "capabilities" => array('manage_terms','edit_terms','delete_terms','assign_terms'), "rewrite" => array( 'slug' => 'product' )));
I exchanged ‘terms’ for ‘categories’ since I see in the codex there are terms to pass in for both.
ah, yes, probably is manage_categories.
Darn, I really suspected it was a role/capability issue too. Bug?
@andrea_r – sorry but to be clear… are you proposing creating a mu-plugins folder in wp-content and throwing this custom code in there?
I did that just now. I took the code out of functions.php in my theme file and placed it in a new file (custom-tax.php) in a newly created mu-plugins folder.
Unfort. now this statement (which i made more simple for troubleshooting purposes here):
register_taxonomy("Product Categories", array("campaign"));
Is producing this error in the backend on any page load:
Fatal error: Call to a member function add_rewrite_tag() on a non-object in /home/content/04/7653004/html/wp-includes/taxonomy.php on line 333
Full code is below for the file, in case i’m missing something.
http://pastebin.com/a0LEhFtn
Edit: Removed embedded code and replaced w/ pastebin. π
Something must be wonky with the user or theme you are testing with, as I just pasted your code as is in twentyten on a test 3.1.1 install and was able to create a new campaign with a regular site admin on a child site.
Are you sure that user has the admin role for the child site?
@miklb – Yes, the user was created at the same time the child blog was (via the WordPress Network Admin ‘add site’ function).
I can start another blog and do this from twentyten, although literally i’m working with an exact duplicate of it. But worth another try. But let’s be clear – the problem isn’t that I wasn’t able to create a new campaign/post-type, it’s when I attempt to go to the ‘product categories’ custom tax screen is where i get the error.
Ignore me. I see where you are getting that error, when you try to click post tags.
@milkb – To confirm, you are seeing the “cheat’n huh?” wordpress error as well?
Yes. With a normal site admin on a child site with your code, when I click Product Categories, I get the “Cheatin’ uh?” screen.
I will note I’ve managed to be able to create/add new categories from the actual Campaigns edit/add new screens. Just can’t access them from the menu item.
And I can confirm this is a probably a bug in 3.1, as I used similar code in a 3.0.4 install and it works.
Code I used in a 3.1.1 environment and the 3.0.4 install http://pastebin.com/PAVsgabx
I’m not sure why this issue exists, but it has to do with the fact that your taxonomy name (the first parameter in the register_taxonomy() function) uses capital letters. Although it’s not documented (and is most likely a bug), the taxonomy name can only include lowercase letters, hyphens and underscores.
Therefore, change this line:
register_taxonomy('Product_Categories',array('campaign'), array(
to:
register_taxonomy('product_categories',array('campaign'), array(
and it will work.
EDIT – It appears to be related to, though not exactly the same, as the bug reported at http://core.trac.ww.wp.xz.cn/ticket/16600
EDIT AGAIN – Just noticed that it is mentioned in the Codex article, but it’s not extremely obvious. The following quote is currently in the description section of the codex article:
In particular, capital letters should be avoided ()This was allowed in 3.0, but not enforced until 3.1 with the “Cheatin'” error).
@curtiss,
Yep that did it. Many thanks! I should have tried that – literally tried almost everything else. Hopefully someone make a note of that in the codex (maybe me!).
So in summary if you use register_taxonomy(), keep your name in LOWERCASE letters, hyphens, and underscores.
Thanks again @curtiss, @andrea_r, and @miklb.