Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with multiple post-types with same taxonomy :: Two post-types can't have same taxonomy #14

Closed
manojhl opened this issue Apr 20, 2014 · 4 comments

Comments

@manojhl
Copy link

manojhl commented Apr 20, 2014

i created two objects $book and $person, and an taxonomy author_type.

$books->register_taxonomy(array(
    'taxonomy_name' => 'author_type',
));
$person->register_taxonomy(array(
    'taxonomy_name' => 'author_type',
));

but the taxonomy is available for only the last declared object $person but $books did't get the auther_type taxonomy...

I don't know may be i am doing something wrong..

@jjgrainger
Copy link
Owner

When registering the taxonomy to another post type this way, the class uses register_taxonomy_for_object_type (codex), which doesn't seem to be working as expected. I think the taxonomy gets registered to the post type, its the UI doesn't display. So I'll look into fixing this bug when I can.

For now, you could try registering the taxonomy to the post type within its arguments array (codex) like so:

$person = new CPT('person', array(
    'taxonomies' => array('author_type')
));

This should work :)

@manojhl
Copy link
Author

manojhl commented May 6, 2014

I have already tried that but this one also registers the taxonomy once again :D, I took into the register_taxonomy_for_object_type inside core, everything looks fine but don't know the registered taxonomies aren't added in the $wp_taxonomies global.. May be you should localize this global variable inside the CTP itself.....

@manojhl
Copy link
Author

manojhl commented Jun 6, 2014

That's cool man I tried for hours and thought its not possible and moved on but you finally got the solution.
Can you give me brief what was causing that error.

@jjgrainger
Copy link
Owner

The add_action to register the taxonomies was inside the register_taxonomy method of the class, I think this meant the action wasn't registered early enough to run properly and register taxonomies correctly.

By moving the add_action into the __construct method of the class registers the action and taxonomies correctly.

Hope that makes sense :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants