I’m currently displaying custom taxonomies in a drop down menu. Each taxonomy has its own little wrapper in the sidebar. Is it possible to move the taxonomy to inside of my custom write box for ease-of-use purposes?
Leave a Reply
You must be logged in to post a comment.
The following is taken from a “move author to publish box” task, but it should give you a starting point. Next you should take a look at “/wp-admin/edit-form-advanced.php” where you’ll find something about
get_object_taxonomies()
to see how your stuff get’s named, so you can remove and add stuff.I was able to achieve this with custom taxonomies on a metabox I created for a custom post type of mine by doing the following:
First I added this to my
functions.php
:The first parameter of the function
remove_meta_box()
is actually an id generated by WordPress. If you are using non-hierarchical taxonomies (i.e. “Tags”), it will always be “tagsdiv-” followed by your custom taxonomy slug. If it’s a hierarchical taxonomy (i.e. “Category”) the id will be the slug followed by “div”, no spaces.I then put the following code on my metabox template:
Finally, note that in the case of “Keywords” or any other Tag-like taxonomy, this will not be enough. The tags metabox functionality is achieved via JS, which depends on selectors that are not created by the function above. In my case this was solved by adding the class “inside” to the keywords div, and by adding these lines to a separate JS file:
Just make sure to call the JS after WP has loaded the default Post scripts. If for some reason you don’t want to add more scripts, you can achieve the same by mimicking WP’s structure like so: