WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When you add a category in the admin-panel, the adminstrator can select it's parent. Something like:

- Category1
-- Subcategory1 to Category1
-- Subcategory2 to Category1
-- Subcategory3 to Category1
- Category2
-- Subcategory1 to Category2
-- Subcategory2 to Category2
-- Subcategory3 to Category2

I have created a custom taxonomy. Is there a way to change these options to be only parent - selection like this for this specific taxonomy?

- Category1
- Category2


(Is there a hook for this for a taxonomy at all?)

share|improve this question
It can be done but you're going to have to get a bit tricky. You should be able to get the gist of it from the non-hierarchical version of your answer (shibashake.com/wordpress-theme/…). You more or less need to apply the same concept to categories and add the JS handler to populate the second select box. – Imperative Ideas Oct 10 '13 at 8:32
@ImperativeIdeas - Thanks for your línk! I thought the basic idea behind that link was very good, but I think it complicated to much for that special case I had. I've answered myself, so someone else hopefully might got helped in the future. – bestprogrammerintheworld Oct 10 '13 at 15:27

If someone else stumble upon this kind of question, here's my solution to it: (without having to mangage any metaboxes etc)


//Function only showing parent categories when editing or adding new category-courses
function categorycourses_edit_form_fields() {
    <script type="text/javascript">
    jQuery(document).ready( function($) {
       var level = 1;
       //Go down in hierarchy from level1 and remove each level until there are no levels anymore
       //Don't do anything with level-0 because we want to show parent-categories
       while ( level < $("form .form-field #parent").find(".level-" +  level).length>0 ) { 
            $("form .form-field #parent").find(".level-1").remove(); //Remove level

(categorycourses is a taxonomy, and if you wish to use the code just change the taxonomy like



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.