WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP Dropdown Categories Arrangement (2 posts)

  1. Timoxendale
    Member
    Posted 1 year ago #

    Hey, I have been searching around but I couldn’t find what I needed, I was hoping someone would be so nice and help me out.
    So far I have the code:
    <?php wp_dropdown_categories( 'tab_index=10&taxonomy=category&hide_empty=0' ); ?>
    Which displays all the categories in a drop down list, what I am trying to find out is how can I sort the list so it looks like:

    Main category 1
    - sub category 1
    - sub category 2
    Main category 2
    - sub category 1
    - sub category 2
    Main category3
    - sub category 1
    - sub category 2

  2. Timoxendale
    Member
    Posted 1 year ago #

    Worked it out

    `<?php $drop_cat = array(
    'orderby' => 'ID',
    'order' => 'ASC',
    'hide_empty' => 0,
    'hierarchical' => 1,
    'name' => 'cat',
    'tab_index' => 10,
    'taxonomy' => 'category',
    'hide_if_empty' => false
    ); ?>

    <?php wp_dropdown_categories( $drop_cat ); ?> `

Topic Closed

This topic has been closed to new replies.

About this Topic