Title: &lt;?php dropdown_categories(&#8216;arguments&#8217;); ?&gt; (admin function)
Last modified: August 18, 2016

---

# <?php dropdown_categories(‘arguments’); ?> (admin function)

 *  [ezequielzc](https://wordpress.org/support/users/ezequielzc/)
 * (@ezequielzc)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/)
 * First, sorry. This text was translated of the Portuguese for English in the Google.
   
   My doubt is the following one: The function **dropdown_categories()** does not
   allow to add arguments as child_of. That is, **dropdown_categories(“child_of=
   4”)**. Argument found in the function wp_list_categories. Has some form of I 
   to obtain to modify this function dropdown_categories to use the attribute child_of?
   It would thank the aid very.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/#post-630156)
 * Better to use the [template tag](http://codex.wordpress.org/Template_Tags), [wp_dropdown_categories()](http://codex.wordpress.org/Template_Tags/wp_dropdown_categories).
 *  Thread Starter [ezequielzc](https://wordpress.org/support/users/ezequielzc/)
 * (@ezequielzc)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/#post-630235)
 * This tag is a “Template Tag” and not one “admin function”. Until I tried uses
   it, but it does not function. One presents in <“ul”> and to another one in dropdown.
   E still thus the parameters are different.
 *  Thread Starter [ezequielzc](https://wordpress.org/support/users/ezequielzc/)
 * (@ezequielzc)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/#post-630270)
 * I am creating new pages as post-new.php/edit-form-advanced.php.
    What I want 
   is to restrict categories, showing the children of the category mother “X”. To
   post. Get it?
 *  Thread Starter [ezequielzc](https://wordpress.org/support/users/ezequielzc/)
 * (@ezequielzc)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/#post-630335)
 * ?! :,|
 *  [smalps](https://wordpress.org/support/users/smalps/)
 * (@smalps)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/#post-630416)
 * Hey ezeuielzc:
 * I had a similar goal; I wanted to restrict access to categories based on the 
   user’s role. This is how I did it:
 * 1. In /wp-admin/includes/template.php –
 * I replaced this line:
    `$cats = get_categories("parent=$parent&hide_empty=0&fields
   =ids");`
 * With this:
 *     ```
       if (!$parent) {
          $cats = get_categories("parent=$parent&hide_empty=0&fields=ids");
       } else {
       $cats = get_categories("child_of=$parent&hide_empty=0&fields=ids");
       }
       ```
   
 * 2. /wp-admin/includes/template.php –
 * I replaced this function:
 *     ```
       function dropdown_categories( $default = 0 ) {
       	write_nested_categories( get_nested_categories( $default) );
       }
       ```
   
 * With this function:
 *     ```
       function dropdown_categories( $default = 0, $parent = 0 ) {
       	write_nested_categories( get_nested_categories( $default, $parent) );
       }
       ```
   
 * 3. /wp-admin/edit-form-advanced.php –
 * I replaced this line:
    `<ul id="categorychecklist"><?php dropdown_categories();?
   ></ul></div>`
 * With this line:
    `<ul id="categorychecklist"><?php if ( !current_user_can('manage_categories')){
   dropdown_categories(0,5); } else { dropdown_categories();} ?></ul></div>`
 * 5 – being my category ID which I wanted only the child of.
    I used !current_user_can
   to control when this would be called. Currently child_of 5 is only called when
   the user is no admin or editor.
 * * – If there is a new update this will most likely be overwritten.
 *  [raduma](https://wordpress.org/support/users/raduma/)
 * (@raduma)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/#post-630453)
 * smalps, looks easy, one small problem thou.. can’t find that /wp-admin/includes/
   template.php you’re talking about.
 * in my wp-admin i only have the images and import directories and the rest of 
   css, js and phps… no includes nor template.php.
 * i desperately want to restrict access to categories based on the user’s role,
   so plizzzzz help me find the .php i’m looking for 😀

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘<?php dropdown_categories(‘arguments’); ?> (admin function)’ is closed
to new replies.

 * 6 replies
 * 4 participants
 * Last reply from: [raduma](https://wordpress.org/support/users/raduma/)
 * Last activity: [18 years, 3 months ago](https://wordpress.org/support/topic/ltphp-dropdown_categoriesarguments-gt-admin-function-help/#post-630453)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
