• nickpartyka

    (@nickpartyka)


    How can I make the “Select category” option the first in the drop down list? It will only put “Show all posts” as the first option. this is my code:

    <?php $args = array('show_option_none' => 'Select category',
    'show_option_all' => 'Show all posts'); ?>
    <?php wp_dropdown_categories( $args ); ?>

    and this is the outputted html:

    <select name='cat' id='cat' class='postform' >
    	<option value='0'>Show all posts</option>
    	<option value='-1'>Select category</option>
    	<option class="level-0" value="1">Uncategorized</option>
    	<option class="level-0" value="8">Blog</option>
    </select>

    you’d think that a simple 'orderby' => 'ID' or 'orderby' => 'value' would do it, but it doesnt.. i don’t want to just make the “select category” the selected option by default because then when you’re on a specific category page it will still be selected. i just want to change the output to this:

    <select name='cat' id='cat' class='postform' >
    	<option value='-1'>Select category</option>
    	<option value='0'>Show all posts</option>
    	<option class="level-0" value="1">Uncategorized</option>
    	<option class="level-0" value="8">Blog</option>
    </select>

Viewing 1 replies (of 1 total)
  • which .php file did you find that from? I’m trying to do the same thing but with no luck. Would like to figure it out together =)

Viewing 1 replies (of 1 total)
  • The topic ‘How can I make "Select category" first option in category select dropdown?’ is closed to new replies.