how to get value of wp_dropdown_categories

We can get the categories via get_categories() function (which will get the same categories as wp_dropdown_categories() function), but as array and without the markup. As the value is returned as array, we can loop through the categories and generate the HTML ourself. Usually, we would aim for a structure like this: <select name=”categories”> <option value=”1″>Category … Read more

wp_dropdown_categories in custom post type with custom taxonomy

get post id $post_id=get_the_ID(); get selected region $terms = wp_get_post_terms( $post_id, $taxonomy ); $selected_id=”; if(isset($terms[0]->term_id)){ $selected_id=$terms[0]->term_id; } build hierarchical dropdown wp_dropdown_categories( array( ‘show_option_all’ => ‘Choose a region’, ‘show_option_none’ => ”, ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ‘show_count’ => 0, ‘hide_empty’ => 0, ‘child_of’ => 0, ‘exclude’ => ”, ‘echo’ => 1, ‘selected’ => $selected_id, ‘hierarchical’ … Read more

Add a dropdown to theme customizer

Add Section to Theme Customizer: $wp_customize->add_section( ‘parsmizban_options’, array( ‘title’ => __( ‘Theme Options’, ‘parsmizban’ ), //Visible title of section ‘priority’ => 20, //Determines what order this appears in ‘capability’ => ‘edit_theme_options’, //Capability needed to tweak ‘description’ => __(‘Allows you to customize settings for Theme.’, ‘parsmizban’), //Descriptive tooltip ) ); Add new Setting: $wp_customize->add_setting( ‘bootstrap_theme_name’, //No … Read more

Custom Taxonomy as Dropdown in admin

This suppose you have a custom post type “sponsors” and a custom taxonomy “types”… function custom_meta_box() { remove_meta_box( ‘tagsdiv-types’, ‘sponsors’, ‘side’ ); add_meta_box( ‘tagsdiv-types’, ‘Types’, ‘types_meta_box’, ‘sponsors’, ‘side’ ); } add_action(‘add_meta_boxes’, ‘custom_meta_box’); /* Prints the taxonomy box content */ function types_meta_box($post) { $tax_name=”types”; $taxonomy = get_taxonomy($tax_name); ?> <div class=”tagsdiv” id=”<?php echo $tax_name; ?>”> <div class=”jaxtag”> … Read more

Removing filter dropdown in posts table (in this case Yoast SEO)

These additional dropdowns are added via the restrict_manage_posts action hook. This means the dropdown output isn’t filterable, but you can remove the hooked action from Yoast SEO. The filter dropdown is added by the posts_filter_dropdown() method in the WPSEO_Metabox class. It’s added in the setup_page_analysis() method of the same class, which is hooked into admin_init … Read more

Taxonomy dropdown metabox in the back-end

Here is an example. I have also created a Gist with more generic code. add_action(‘add_meta_boxes’, ‘my_custom_metabox’); function my_custom_metabox() { add_meta_box(‘custom-taxonomy-dropdown’,’Brands’,’taxonomy_dropdowns_box’,’post’,’side’,’high’); } function taxonomy_dropdowns_box( $post ) { wp_nonce_field(‘custom-dropdown’, ‘dropdown-nonce’); $terms = get_terms( ‘brands’, ‘hide_empty=0’); $object_terms = wp_get_object_terms( $post->ID, ‘brands’, array(‘fields’=>’ids’)); // you can move the below java script to admin_head ?> <script type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#custombrandoptions’).change(function() … Read more

How to use wp_nav_menu to create a select menu dropdown?

You can’t do this with wp_nav_menu, because it outputs list items, and you’ll generate invalid markup with your code. Try using wp_get_nav_menu_items() instead. A quick solution for a drop down menu with a custom walker: class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu{ // don’t output children opening tag (`<ul>`) public function start_lvl(&$output, $depth){} // don’t output children closing … Read more

Any docs for wp_nav_menu’s “items_wrap” argument?

The parameter ‘items_wrap’ for wp_nav_menu() defaults to: ‘<ul id=”%1$s” class=”%2$s”>%3$s</ul>’ This a a template that is parsed with sprintf(): $nav_menu .= sprintf( $args->items_wrap , esc_attr( $wrap_id ) // %1$s , esc_attr( $wrap_class ) // %2$s , $items // %3$s ); The numbered placeholders – %1$s, %2$s, %3$s – refer to the arguments after the first … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)