0

I have a custom post type created, with custom meta boxes for it setup and a custom taxonomy type for that post type. Now I'm looking to (i.e. Via jQuery) display certain meta boxes based on the taxonomies selected (each taxonomy has different options that needs to be filled out)

Any suggestions on the best way to go about this or if it's even possible?

I've got the bulk of the work done I just need to conditionally display (a) specific meta box(s) based on the taxonomy(s) selected..

Braunson
  • 717
  • 2
  • 12
  • 36
  • Attach an on change function to your taxonomy check boxes and then show/hide the related meta box. – Jared Feb 14 '13 at 20:34
  • I think you're looking for dependent dropdowns. http://stackoverflow.com/questions/5910281/jquery-dependent-drop-down-boxes-populate-how – Matt Feb 14 '13 at 20:34
  • @mkaatman I really didn't want to use dependent dropdowns since multiple taxonomy items can be selected. I mean there is multiple select, but in this case that's no an option (UX purposes). – Braunson Feb 14 '13 at 20:37
  • @Jrod, how would you do this, do you mean you would do this via code dynamically or hard code it? – Braunson Feb 14 '13 at 20:38
  • @Braunson Can you setup a jsfiddle mocking up what you'd like to achieve? Could you put all the options for each taxonomy in its own hidden div and then when the taxonomy is clicked display that div full of options? – Matt Feb 14 '13 at 20:48
  • @mkaatman Here's a rough js fiddle - http://jsfiddle.net/PADk2/ From the information I've found so far, it seems there isn't any dynamic solution to this to dynamically link metabox with x taxonomy. – Braunson Feb 14 '13 at 21:00
  • @Braunson from your fiddle it seems you have it working... I am really not sure what the problem is? If you used the actual names or your metaboxes, custom post type and taxonmies it might be easier to understand. – Jared Feb 14 '13 at 21:04
  • 1
    @braunson I've updated it slightly, what functionality is missing? It seems like you're accomplishing my understanding of what you're trying to accomplish. http://jsfiddle.net/PADk2/1/ – Matt Feb 14 '13 at 21:07
  • @makaatman My apologies for not being specific, I have wordpress dynamically generate metaboxes for a custom post type, now would I inject js into a custom post type "add new" page. I guess I could hard code the metaboxes in, then add a class to have the various one's hidden onload, and then on click of each taxonomy type, take the slug and display the metabox. It's nothing dynamic which is what I was hoping for but it'll work. – Braunson Feb 14 '13 at 21:11

1 Answers1

0

So the entire goal was to have custom meta boxes display for the on selection of different taxonomies (each taxonomie displays a different meta box with different options). It seems there's no way to dynamically achieve this as of yet so the only solution is this.

  1. Code up the various metaboxes for each taxonomy within functions.php
  2. Assign the boxes to be hidden a certain class to display:none and on check of the slug of the taxonomy that matches the metaboxes id, display the box.

This was also informative when injecting JS into the Wordpress backend for a speciflc content post type / page. https://wordpress.stackexchange.com/questions/1058/loading-external-scripts-in-admin-but-only-for-a-specific-post-type

Answered.

Community
  • 1
  • 1
Braunson
  • 717
  • 2
  • 12
  • 36