Selected attribute of Drop down list

Your code looks alright. Because your selected output at right place in your screenshot. I have tried to reproduce the problem but seems all browsers are working correctly. Maybe you could just create a very simple template without other code to interfere. Sometimes, a broken HTML structure may also affect. I tested it both in … Read more

How to number the options in a wp_dropdown_pages() select?

To change <option value=”http://someurl”>item one</option> <option value=”http://someurl”>item two</option> <option value=”http://someurl”>item three</option> to <option value=”http://someurl”>1. item one</option> <option value=”http://someurl”>2. item two</option> <option value=”http://someurl”>3. item three</option> we can utilize the list_pages filter from the Walker_PageDropdown::start_el() method. Here’s an example: // Add filter add_filter( ‘list_pages’, ‘wpse_itemize’, 10, 2 ); // Display dropdown wp_dropdown_pages(); // Remove filter remove_filter( ‘list_pages’, … Read more

Drop-down menu with wp_dropdown_pages

First of all, i think you got an error in your arguments. It should be ‘show_option_none’ => ‘Select Page’, not ‘show_option_none=Select Page’. Secondly: Shortcodes are things that are replaced within the content of the post/page/whatever. This means that the content of the Shortcode has to be returned. You directly echo them, which leads to the … Read more

Add submenu using the bootstrap wp_nav_menu

You will need to write a custom menu walker. See this code for the walker. (Or do a search for “Bootstrap Menu Walker”.) Then use: wp_nav_menu( array( ‘menu’ => ‘header’, ‘menu_class’ => ‘nav nav-pills’, ‘container’ => ‘nav’, ‘container_class’ => $classes, ‘fallback_cb’ => false, ‘depth’ => 2, ‘walker’ => new Bootstrap_Walker_Menu_Nav(), ‘theme_location’ => ‘header’, ‘echo’ => … Read more

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

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