wp_dropdown_pages

The timeline below displays how wordpress function wp_dropdown_pages has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

//
// Pages.
//
/**
 * Retrieves or displays a list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @see get_pages()
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page dropdown. See get_pages() for additional arguments.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML dropdown list of pages.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $parsed_args = wp_parse_args($args, $defaults);
    $pages = get_pages($parsed_args);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument.
    if (empty($parsed_args['id'])) {
        $parsed_args['id'] = $parsed_args['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($parsed_args['class'])) {
            $class = " class='" . esc_attr($parsed_args['class']) . "'";
        }
        $output = "<select name='" . esc_attr($parsed_args['name']) . "'" . $class . " id='" . esc_attr($parsed_args['id']) . "'>\n";
        if ($parsed_args['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
        }
        if ($parsed_args['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($parsed_args['option_none_value']) . '">' . $parsed_args['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $parsed_args['depth'], $parsed_args);
        $output .= "</select>\n";
    }
    /**
     * Filters the HTML output of a list of pages as a dropdown.
     *
     * @since 2.1.0
     * @since 4.4.0 `$parsed_args` and `$pages` added as arguments.
     *
     * @param string    $output      HTML output for dropdown list of pages.
     * @param array     $parsed_args The parsed arguments array. See wp_dropdown_pages()
     *                               for information on accepted arguments.
     * @param WP_Post[] $pages       Array of the page objects.
     */
    $html = apply_filters('wp_dropdown_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 5.7

//
// Pages.
//
/**
 * Retrieve or display a list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @see get_pages()
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page dropdown. See `get_pages()` for additional arguments.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML dropdown list of pages.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $parsed_args = wp_parse_args($args, $defaults);
    $pages = get_pages($parsed_args);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument.
    if (empty($parsed_args['id'])) {
        $parsed_args['id'] = $parsed_args['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($parsed_args['class'])) {
            $class = " class='" . esc_attr($parsed_args['class']) . "'";
        }
        $output = "<select name='" . esc_attr($parsed_args['name']) . "'" . $class . " id='" . esc_attr($parsed_args['id']) . "'>\n";
        if ($parsed_args['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
        }
        if ($parsed_args['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($parsed_args['option_none_value']) . '">' . $parsed_args['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $parsed_args['depth'], $parsed_args);
        $output .= "</select>\n";
    }
    /**
     * Filters the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     * @since 4.4.0 `$parsed_args` and `$pages` added as arguments.
     *
     * @param string    $output      HTML output for drop down list of pages.
     * @param array     $parsed_args The parsed arguments array. See wp_dropdown_pages()
     *                               for information on accepted arguments.
     * @param WP_Post[] $pages       Array of the page objects.
     */
    $html = apply_filters('wp_dropdown_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 5.4

//
// Pages.
//
/**
 * Retrieve or display a list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @see get_pages()
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page dropdown. See `get_pages()` for additional arguments.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML dropdown list of pages.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $parsed_args = wp_parse_args($args, $defaults);
    $pages = get_pages($parsed_args);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument.
    if (empty($parsed_args['id'])) {
        $parsed_args['id'] = $parsed_args['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($parsed_args['class'])) {
            $class = " class='" . esc_attr($parsed_args['class']) . "'";
        }
        $output = "<select name='" . esc_attr($parsed_args['name']) . "'" . $class . " id='" . esc_attr($parsed_args['id']) . "'>\n";
        if ($parsed_args['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
        }
        if ($parsed_args['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($parsed_args['option_none_value']) . '">' . $parsed_args['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $parsed_args['depth'], $parsed_args);
        $output .= "</select>\n";
    }
    /**
     * Filters the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     * @since 4.4.0 `$parsed_args` and `$pages` added as arguments.
     *
     * @param string    $output      HTML output for drop down list of pages.
     * @param array     $parsed_args The parsed arguments array.
     * @param WP_Post[] $pages       Array of the page objects.
     */
    $html = apply_filters('wp_dropdown_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 5.3

//
// Pages
//
/**
 * Retrieve or display a list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @see get_pages()
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page dropdown. See `get_pages()` for additional arguments.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $parsed_args = wp_parse_args($args, $defaults);
    $pages = get_pages($parsed_args);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($parsed_args['id'])) {
        $parsed_args['id'] = $parsed_args['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($parsed_args['class'])) {
            $class = " class='" . esc_attr($parsed_args['class']) . "'";
        }
        $output = "<select name='" . esc_attr($parsed_args['name']) . "'" . $class . " id='" . esc_attr($parsed_args['id']) . "'>\n";
        if ($parsed_args['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
        }
        if ($parsed_args['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($parsed_args['option_none_value']) . '">' . $parsed_args['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $parsed_args['depth'], $parsed_args);
        $output .= "</select>\n";
    }
    /**
     * Filters the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     * @since 4.4.0 `$parsed_args` and `$pages` added as arguments.
     *
     * @param string $output      HTML output for drop down list of pages.
     * @param array  $parsed_args The parsed arguments array.
     * @param array  $pages       List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_dropdown_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 5.1

//
// Pages
//
/**
 * Retrieve or display a list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @see get_pages()
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page dropdown. See `get_pages()` for additional arguments.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $r = wp_parse_args($args, $defaults);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($r['id'])) {
        $r['id'] = $r['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($r['class'])) {
            $class = " class='" . esc_attr($r['class']) . "'";
        }
        $output = "<select name='" . esc_attr($r['name']) . "'" . $class . " id='" . esc_attr($r['id']) . "'>\n";
        if ($r['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
        }
        if ($r['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($r['option_none_value']) . '">' . $r['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $r['depth'], $r);
        $output .= "</select>\n";
    }
    /**
     * Filters the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     * @since 4.4.0 `$r` and `$pages` added as arguments.
     *
     * @param string $output HTML output for drop down list of pages.
     * @param array  $r      The parsed arguments array.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_dropdown_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.6

//
// Pages
//
/**
 * Retrieve or display list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a pages drop-down element.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $r = wp_parse_args($args, $defaults);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($r['id'])) {
        $r['id'] = $r['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($r['class'])) {
            $class = " class='" . esc_attr($r['class']) . "'";
        }
        $output = "<select name='" . esc_attr($r['name']) . "'" . $class . " id='" . esc_attr($r['id']) . "'>\n";
        if ($r['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
        }
        if ($r['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($r['option_none_value']) . '">' . $r['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $r['depth'], $r);
        $output .= "</select>\n";
    }
    /**
     * Filters the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     * @since 4.4.0 `$r` and `$pages` added as arguments.
     *
     * @param string $output HTML output for drop down list of pages.
     * @param array  $r      The parsed arguments array.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_dropdown_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.4

//
// Pages
//
/**
 * Retrieve or display list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a pages drop-down element.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $r = wp_parse_args($args, $defaults);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($r['id'])) {
        $r['id'] = $r['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($r['class'])) {
            $class = " class='" . esc_attr($r['class']) . "'";
        }
        $output = "<select name='" . esc_attr($r['name']) . "'" . $class . " id='" . esc_attr($r['id']) . "'>\n";
        if ($r['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
        }
        if ($r['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($r['option_none_value']) . '">' . $r['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $r['depth'], $r);
        $output .= "</select>\n";
    }
    /**
     * Filter the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     * @since 4.4.0 `$r` and `$pages` added as arguments.
     *
     * @param string $output HTML output for drop down list of pages.
     * @param array  $r      The parsed arguments array.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_dropdown_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.3

//
// Pages
//
/**
 * Retrieve or display list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 * @since 4.3.0 The `$class` argument was added.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a pages drop-down element.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $r = wp_parse_args($args, $defaults);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($r['id'])) {
        $r['id'] = $r['name'];
    }
    if (!empty($pages)) {
        $class = '';
        if (!empty($r['class'])) {
            $class = " class='" . esc_attr($r['class']) . "'";
        }
        $output = "<select name='" . esc_attr($r['name']) . "'" . $class . " id='" . esc_attr($r['id']) . "'>\n";
        if ($r['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
        }
        if ($r['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($r['option_none_value']) . '">' . $r['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $r['depth'], $r);
        $output .= "</select>\n";
    }
    /**
     * Filter the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     *
     * @param string $output HTML output for drop down list of pages.
     */
    $html = apply_filters('wp_dropdown_pages', $output);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.2

//
// Pages
//
/**
 * Retrieve or display list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 * @since 4.2.0 The `$value_field` argument was added.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a pages drop-down element.
 *
 *     @type int          $depth                 Maximum depth. Default 0.
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
 *                                               or their bool equivalents. Default 1.
 *     @type string       $name                  Value for the 'name' attribute of the select element.
 *                                               Default 'page_id'.
 *     @type string       $id                    Value for the 'id' attribute of the select element.
 *                                               Defaults to the value of `$name`.
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
 *                                               elements. Accepts any valid post field. Default 'ID'.
 * }
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID');
    $r = wp_parse_args($args, $defaults);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($r['id'])) {
        $r['id'] = $r['name'];
    }
    if (!empty($pages)) {
        $output = "<select name='" . esc_attr($r['name']) . "' id='" . esc_attr($r['id']) . "'>\n";
        if ($r['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
        }
        if ($r['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($r['option_none_value']) . '">' . $r['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $r['depth'], $r);
        $output .= "</select>\n";
    }
    /**
     * Filter the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     *
     * @param string $output HTML output for drop down list of pages.
     */
    $html = apply_filters('wp_dropdown_pages', $output);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.0

//
// Pages
//
/**
 * Retrieve or display list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 *
 * @param array|string $args Optional. Override default arguments.
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '');
    $r = wp_parse_args($args, $defaults);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($r['id'])) {
        $r['id'] = $r['name'];
    }
    if (!empty($pages)) {
        $output = "<select name='" . esc_attr($r['name']) . "' id='" . esc_attr($r['id']) . "'>\n";
        if ($r['show_option_no_change']) {
            $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
        }
        if ($r['show_option_none']) {
            $output .= "\t<option value=\"" . esc_attr($r['option_none_value']) . '">' . $r['show_option_none'] . "</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $r['depth'], $r);
        $output .= "</select>\n";
    }
    /**
     * Filter the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     *
     * @param string $output HTML output for drop down list of pages.
     */
    $html = apply_filters('wp_dropdown_pages', $output);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 3.9

//
// Pages
//
/**
 * Retrieve or display list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 *
 * @param array|string $args Optional. Override default arguments.
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($id)) {
        $id = $name;
    }
    if (!empty($pages)) {
        $output = "<select name='" . esc_attr($name) . "' id='" . esc_attr($id) . "'>\n";
        if ($show_option_no_change) {
            $output .= "\t<option value=\"-1\">{$show_option_no_change}</option>";
        }
        if ($show_option_none) {
            $output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">{$show_option_none}</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $depth, $r);
        $output .= "</select>\n";
    }
    /**
     * Filter the HTML output of a list of pages as a drop down.
     *
     * @since 2.1.0
     *
     * @param string $output HTML output for drop down list of pages.
     */
    $output = apply_filters('wp_dropdown_pages', $output);
    if ($echo) {
        echo $output;
    }
    return $output;
}

WordPress Version: 3.7

//
// Pages
//
/**
 * Retrieve or display list of pages as a dropdown (select list).
 *
 * @since 2.1.0
 *
 * @param array|string $args Optional. Override default arguments.
 * @return string HTML content, if not displaying.
 */
function wp_dropdown_pages($args = '')
{
    $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $pages = get_pages($r);
    $output = '';
    // Back-compat with old system where both id and name were based on $name argument
    if (empty($id)) {
        $id = $name;
    }
    if (!empty($pages)) {
        $output = "<select name='" . esc_attr($name) . "' id='" . esc_attr($id) . "'>\n";
        if ($show_option_no_change) {
            $output .= "\t<option value=\"-1\">{$show_option_no_change}</option>";
        }
        if ($show_option_none) {
            $output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">{$show_option_none}</option>\n";
        }
        $output .= walk_page_dropdown_tree($pages, $depth, $r);
        $output .= "</select>\n";
    }
    $output = apply_filters('wp_dropdown_pages', $output);
    if ($echo) {
        echo $output;
    }
    return $output;
}