0

I need to add a custom option to wp_dropdown_categories. Now, the whole wide web world haven't gotten a solution for that ... therefore I ask for a solution here … as I can't really imagine that the developers of WordPress have not considered that this would not ever be needed, right?

1
  • 1
    What do you mean with 'custom option'? An extra argument that can be passed to the function? What do you want it to achieve?
    – cjbj
    Commented Jun 8, 2018 at 12:25

1 Answer 1

0

You can do like this

  add_filter( 'wp_dropdown_cats', 'add_yet_another_option', 10, 2 );

  function add_yet_another_option( $output, $r ){
    $output = str_replace( '</select>','',$output ); // remove closing select tag
    $output .= '<option class="level-0" value="some-value"> Some Custom Options </option>'; // custom option. 
    $output .= '</select>'; // add closing select tag
    return $output;
  }

But why would someone put custom option on the category dropdown ?

1
  • It's a client asking for it ... and as you probably already know: clients are stupid ; ). But thanks, I'll check it out.
    – SVDelle
    Commented Jun 10, 2018 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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