wp_dropdown_categories example

$dropdown_options = array(
                'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
                'hide_empty'      => 0,
                'hierarchical'    => 1,
                'show_count'      => 0,
                'orderby'         => 'name',
                'selected'        => $cat,
            );

            echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>';

            wp_dropdown_categories( $dropdown_options );
        }
    }

    /** * Displays a formats drop-down for filtering items. * * @since 5.2.0 * @access protected * * @param string $post_type Post type slug. */
    
$show_option_all = '';
    if ( $optionall )
        $show_option_all = $all;

    $show_option_none = '';
    if ( $optionnone )
        $show_option_none = __('None');

    $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
                    'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
    $query = add_query_arg($vars, '');
    return wp_dropdown_categories($query);
}

/** * Lists authors. * * @since 1.2.0 * @deprecated 2.1.0 Use wp_list_authors() * @see wp_list_authors() * * @param bool $optioncount * @param bool $exclude_admin * @param bool $show_fullname * @param bool $hide_empty * @param string $feed * @param string $feed_image * @return null|string */

                    $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );

                    wp_dropdown_categories( $parent_dropdown_args );
                    ?> <input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" /> <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> <span id="<?php echo $tax_name; ?>-ajax-response"></span> </p> </div> <?php endif; ?> </div> <?php }

'name'             => 'parent',
                    'orderby'          => 'name',
                    'selected'         => $tag->parent,
                    'exclude_tree'     => $tag->term_id,
                    'hierarchical'     => true,
                    'show_option_none' => __( 'None' ),
                    'aria_describedby' => 'parent-description',
                );

                /** This filter is documented in wp-admin/edit-tags.php */
                $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args$taxonomy, 'edit' );
                wp_dropdown_categories( $dropdown_args );
                ?> <?php if ( 'category' === $taxonomy ) : ?> <p class="description" id="parent-description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p> <?php else : ?> <p class="description" id="parent-description"><?php echo $tax->labels->parent_field_description; ?></p> <?php endif; ?> </td> </tr> <?php endif; // is_taxonomy_hierarchical() ?> <tr class="form-field term-description-wrap"> <th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th> <td><textarea name="description" id="description" rows="5" cols="50" class="large-text" aria-describedby="description-description">
$add = array(
            'what'     => $taxonomy->name,
            'id'       => $term_id,
            'data'     => str_replace( array( "\n", "\t" ), '', $data ),
            'position' => -1,
        );
    }

    ob_start();

    wp_dropdown_categories(
        array(
            'taxonomy'         => $taxonomy->name,
            'hide_empty'       => 0,
            'name'             => 'new' . $taxonomy->name . '_parent',
            'orderby'          => 'name',
            'hierarchical'     => 1,
            'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;',
        )
    );

    $sup = ob_get_clean();

    
'name'            => 'cat_id',
                'taxonomy'        => 'link_category',
                'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items,
                'hide_empty'      => true,
                'hierarchical'    => 1,
                'show_count'      => 0,
                'orderby'         => 'name',
            );

            echo '<label class="screen-reader-text" for="cat_id">' . get_taxonomy( 'link_category' )->labels->filter_by_item . '</label>';

            wp_dropdown_categories( $dropdown_options );

            submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
            ?> </div> <?php     }

    /** * @return string[] Array of column titles keyed by their column name. */
    public function get_columns() {
        
_e( 'Content to export' );
    ?> </legend> <input type="hidden" name="download" value="true" /> <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p> <p class="description" id="all-content-desc"><?php _e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus, and custom posts.' ); ?></p> <p><label><input type="radio" name="content" value="posts" /> <?php _ex( 'Posts', 'post type general name' ); ?></label></p> <ul id="post-filters" class="export-filters"> <li> <label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span> <?php wp_dropdown_categories( array( 'show_option_all' => __( 'All' ) ) ); ?> </label> </li> <li> <label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span> <?php         $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
        wp_dropdown_users(
            array(
                'include'         => $authors,
                'name'            => 'post_author',
                'multi'           => true,
                
/** * Filters the arguments for the Categories widget drop-down. * * @since 2.8.0 * @since 4.9.0 Added the `$instance` parameter. * * @see wp_dropdown_categories() * * @param array $cat_args An array of Categories widget drop-down arguments. * @param array $instance Array of settings for the current widget. */
            wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args$instance ) );

            echo '</form>';

            $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
            ?> <script<?php echo $type_attr; ?>> /* <![CDATA[ */ (function() { var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" ); function onCatChange() { if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { dropdown.parentNode.submit(); } } dropdown.onchange = onCatChange; })(); /* ]]> */ </script>
<?php checked( '1', get_option( 'use_smilies' ) ); ?> /> <?php _e( 'Convert emoticons like <code>:-)</code> and <code>:-P</code> to graphics on display' ); ?></label><br /> <label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked( '1', get_option( 'use_balanceTags' ) ); ?> /> <?php _e( 'WordPress should correct invalidly nested XHTML automatically' ); ?></label> </fieldset></td> </tr> <?php endif; ?> <tr> <th scope="row"><label for="default_category"><?php _e( 'Default Post Category' ); ?></label></th> <td> <?php wp_dropdown_categories(
    array(
        'hide_empty'   => 0,
        'name'         => 'default_category',
        'orderby'      => 'name',
        'selected'     => get_option( 'default_category' ),
        'hierarchical' => true,
    )
);
?> </td> </tr>
'hide_empty'   => empty( $attributes['showEmpty'] ),
    );
    if ( ! empty( $attributes['showOnlyTopLevel'] ) && $attributes['showOnlyTopLevel'] ) {
        $args['parent'] = 0;
    }

    if ( ! empty( $attributes['displayAsDropdown'] ) ) {
        $id                       = 'wp-block-categories-' . $block_id;
        $args['id']               = $id;
        $args['show_option_none'] = __( 'Select Category' );
        $wrapper_markup           = '<div %1$s><label class="screen-reader-text" for="' . esc_attr( $id ) . '">' . __( 'Categories' ) . '</label>%2$s</div>';
        $items_markup             = wp_dropdown_categories( $args );
        $type                     = 'dropdown';

        if ( ! is_admin() ) {
            // Inject the dropdown script immediately after the select dropdown.             $items_markup = preg_replace(
                '#(?<=</select>)#',
                build_dropdown_script_block_core_categories( $id ),
                $items_markup,
                1
            );
        }
    }

        $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args$taxonomy, 'new' );

        $dropdown_args['aria_describedby'] = 'parent-description';

        wp_dropdown_categories( $dropdown_args );
        ?> <?php if ( 'category' === $taxonomy ) : ?> <p id="parent-description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p> <?php else : ?> <p id="parent-description"><?php echo $tax->labels->parent_field_description; ?></p> <?php endif; ?> </div> <?php endif; // is_taxonomy_hierarchical() ?> <div class="form-field term-description-wrap"> <label for="tag-description"><?php _e( 'Description' ); ?></label> <textarea name="description" id="tag-description" rows="5" cols="40" aria-describedby="description-description"></textarea> <p id="description-description">
Home | Imprint | This part of the site doesn't use cookies.