Multiple Post Types in same custom taxonomy
-
I have a project that requires multiple custom post types to be in the same custom taxonomy. I also need to be able to manually sort all custom post types in that custom taxonomy. Is it possible with this plugin?
Thanks in advance.
-
that’s a good question, and frankly I don’t know. You’ll need to run a test on a sample site to figure it out. I would need to dive into the code to give you a concrete answer, but I got a feeling it should be possible to make it work with a a few tweaks if it isn’t working already.
It would be great to have that functionality. Let me know if you test this out.
Thanks for the quick response. It does not work and seems to have issues. I ordered perfectly within one custom post type. However, when I went to order the other custom post type using the same taxonomy it shows errors due to how it only grabs posts from the same post type.
I need to have something working sooner rather than later and may just create a separate plugin to accomplish this. I was hoping this functionality was already in a plugin.
Thanks for the plugin.
Want to try to make it work in this plugin? You could submit a PR in the github repo.
I could give you pointers as to how to get it to work.
- This reply was modified 7 years, 10 months ago by Aurovrata Venet.
So I got it to work in a very hackish way. I am not sure of the direction you are going with this plugin. I would be happy to share my code to contribute to the plugin but without any guidance on your future plans I am unsure what the best method to handle such requests. In a brief summary, I added a link to reorder under Posts in the left menu using a copy of the function add_order_pages and naming it add_generic_order_pages with some modifications to use printGenericOrderPage, instead of printOrderPage. A better location for the link would be ideal. I then removed all restrictions of post_types in the printGernericOrderPage function.
I can clean it up if you want or I can send you the updated file. so that you can clean up. As a small side note. There are errors that I found when trying to accomplish all this. If someone has a taxonomy that has multiple post types and then tries to reorder the posts in each post types, errors will occur since the code is requesting a particular post type. My suggestion is to have the database track post type taxonomy relationship order or just open it up to all post types and not limit it.
Please let me know how you feel it should be and I can clean up and send PR.
Great! The main thing is that you have now got a solution for your immediate need.
I would be happy to get the code to see how you got it to work. If you have it forked in github, do share the repo and I will take a look at it, else send me a copy (vrata at syllogic dot in).
As for future direction, the truth is this plugin ain’t my code originally. The author abandoned the plugin and I started to maintain a gitHub repo to fix bugs as I and several other people found this plugin really useful. Now WP allows abandoned plugins to be adopted and I did just that.
I have added very little extra functionality since then, mainly using filters to allow others to hook custom functionality.
I would like to see if we can enable your solution with a hook in the short-term.
in the long term I would like to,
- re-code the plugin using BoilerPlate 3.0 plugin template as I find it much easier to maintain
- re-organise the dashboard interaction to make it a little more intuitive
wrt the 2nd point, were would you see your reorder page menu in the dashboard? Maybe under the Appearance section, as a theme customization section?
I have forked the repo and added the fix. You can find it, with the fix, here. Again this is a hack. If you would like some help on moving over to BoilerPlate 3.0 and reorganize the plugin, I would be happy to help. This code seems like I might be needing and reusing this for the project in many aspects. I am sure I am not the only person in the world that has a need for this.
Hi @vgj
thanks for sharing the repo, sorry for this late reply, I got caught up with other work.
The help to refactor the code is much welcomed. I will start to look at your code and setup a new branch on github on which we can start to collaborate on the BP3.0 template structure.
Give me a few weeks, as I have quite a lot on my plate right now. I will post back on this thread once I am ready.
HI @vgj
I have been thinking about the next evolution of this plugin and I am inclined to explore the possibility of enabling the ordering using WP-core functionality. Currently the plugin makes use of a custom table to store the term orders, but I think we could do away with that and instead store the order within each post as a meta field.
Each post associated with a term would have the following meta field construct,
_reorder-posts_<taxonomy-slug>_<term-id> = <zero based order index>
this approach solves your problem nicely since we are no longer storing the order at the taxonomy/slug level and therefore multiple post types can be ordered for a given taxonomy.
The other advantage is that it allows more control over the display of these ordered posts in theme page templates. A settings would allow a user to either let the plugin manage the post query order automatically, or to allow the user to define the order within the post loop itself, by selecting the
'orderby'=>'meta_value_num'
and setting up the above meta key in the query.What do you think? Can you see any down-side to this approach?
I think this works. At first thought, I do not see any issues. I would like to add that this should work for all post types. But yes, this is a great start.
great, currently I am very busy with some big project involving complex form structures. I am working on a new plugin extension for Contact Form 7 which allows for highly complex forms to be created and formatted as responsive table layouts. I should be done with this project in the month of may I reckon, by which time I should be able to start on this work.
If you are still interested in collaborating, what aspect of the plugin do you feel most confident to take up?
I can always help with anything you need. I am currently busy with an issue and the main culprit is this plugin. It seems to have an issue with trying to get posts in custom wp_query object. When I have more information I will definitely bring them to your attention. Sorry for being vague but I thought I would at least mention it.
- The topic ‘Multiple Post Types in same custom taxonomy’ is closed to new replies.