wp_dropdown_cats() – Legacy function used for generating a categories drop-down control.

You appear to be a bot. Output may be restricted

Description

Legacy function used for generating a categories drop-down control.

Usage

$void|false = wp_dropdown_cats( $current_cat, $current_parent, $category_parent, $level, $categories );

Parameters

$current_cat
( int ) optional – Optional. ID of the current category. Default 0.
$current_parent
( int ) optional – Optional. Current parent category ID. Default 0.
$category_parent
( int ) optional – Optional. Parent ID to retrieve categories for. Default 0.
$level
( int ) optional – Optional. Number of levels deep to display. Default 0.
$categories
( array ) optional – Optional. Categories to include in the control. Default 0.

Returns

void|false Void on success, false if no categories were found.

Source

File name: wordpress/wp-admin/includes/deprecated.php
Lines:

1 to 21 of 21
function wp_dropdown_cats( $current_cat = 0, $current_parent = 0, $category_parent = 0, $level = 0, $categories = 0 ) {
  _deprecated_function( wp_dropdown_cats, '3.0.0', 'wp_dropdown_categories()' );
  if (!$categories )
    $categories = get_categories( array('hide_empty' => 0) );

  if ( $categories ) {
    foreach ( $categories as $category ) {
      if ( $current_cat != $category->term_id && $category_parent == $category->parent) {
        $pad = str_repeat( '– ', $level );
        $category->name = esc_html( $category->name );
        echo "\n\t<option value='$category->term_id'";
        if ( $current_parent == $category->term_id )
          echo " selected='selected'";
        echo ">$pad$category->name</option>";
        wp_dropdown_cats( $current_cat, $current_parent, $category->term_id, $level +1, $categories );
      }
    }
  } else {
    return false;
  }
}
 

 View on GitHub View on Trac