Warning: This function has been deprecated. Use wp_dropdown_categories() instead.

wp_dropdown_cats( int $currentcat, int $currentparent, int $parent, int $level, array $categories )

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


Description Description

See also See also


Top ↑

Parameters Parameters

$currentcat

(int) (Optional) ID of the current category. Default 0.

$currentparent

(int) (Optional) Current parent category ID. Default 0.

$parent

(int) (Optional) Parent ID to retrieve categories for. Default 0.

$level

(int) (Optional) Number of levels deep to display. Default 0.

$categories

(array) (Optional) Categories to include in the control. Default 0.


Top ↑

Return Return

(bool|null) False if no categories were found.



Top ↑

Source Source

File: wp-admin/includes/deprecated.php

function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
	if (!$categories )
		$categories = get_categories( array('hide_empty' => 0) );

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

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Use wp_dropdown_categories()
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.