Get id of category from drop down menu

You’re on the right track with using a form, the only thing you’re missing, you have to submit what you have selected. For example like this: <form method=”GET” action=””> <div> <?php $select = wp_dropdown_categories(‘show_option_none=Select category&orderby=name&echo=0’); $select = preg_replace(“#<select([^>]*)>#”, “<select$1 onchange=”return this.form.submit()”>”, $select); echo $select; ?> <noscript> <div> <input type=”submit” value=”View” /> </div> </noscript> </div> </form> … Read more

Save selected item from dropdown menu in a meta box as a metadata value for a custom post type

$myterms = get_terms($taxonomies, $args); returns an array of term objects. Use $term->term_id as option value … “<option value=”$term->term_id”>”. esc_html( $term_name ) . “</option>” … and store that ID, not the name. Names can change, the IDs will stay the same – unless someone deletes a term and creates a new one with the same name. … Read more

shortcode to create dynamic dropdown box form shortcode attributes

Based on your example at the bottom of your question, and your statement that you would like something like that for readability, I’d do something like this: function dropdown_option($atts) { $dropid = (isset($atts[‘dropid’])) ? $atts[‘dropid’] : ”; global $sco_array; if (!empty($atts[‘value’]) && !empty($atts[‘text’])) { $sco_array[$dropid][$atts[‘value’]] = $atts[‘text’]; } } add_shortcode(‘sco’,’dropdown_option’); function sc_dropdown($atts) { $id = … Read more

How can I display parent and child taxonomies in separate drop downs?

Hello Everyone out there, who are facing difficulty to display the parent and child taxonomies in drop down, i found the solution for the above problem…… edit the code in the functions.php file, before the code was $categories= get_categories(‘child_of=”.$_POST[“main_catid’].’hide_empty=0′); now edit the code, like this… $categories= get_categories(‘child_of=”.$_POST[“main_catid’].’&hide_empty=0′.’&taxonomy=state’); and this works so beautifully, try it for … Read more

No authors in change author dropdown

The role “Reviewer” only has special capabilities, no other capabilities. To get into the author list you have to be at least a contributor or author. function rb_addroles() { $role = get_role(‘contributor’); remove_role( ‘reviewer’ ); add_role( ‘reviewer’, ‘Reviewer’, $role->capabilities ); $reviewer = get_role(‘reviewer’); $reviewer->add_cap( ‘edit_review’ ); $reviewer->add_cap( ‘read_review’ ); $reviewer->add_cap( ‘delete_review’ ); } add_action( ‘admin_init’, … Read more

How can I show drafts in wp_dropdown_pages list?

Update It seems that you can do this directly with WP function wp_dropdown_pages() as birgire points out in his response below: https://wordpress.stackexchange.com/a/240275/102371 This solution is longer, and uses get_posts() to fetch specific post statuses. $pages = get_posts( array( ‘post_type’ => ‘page’, ‘post_parent’ => 0, ‘post_status’ => array( ‘draft’, ‘publish’ ) ) ); echo ‘<select name=”selected-food-type” … Read more

How do I give class to the dropdown sub-menu in the wp_nav_menu?

You can use Walker_Nav_Menu (WordPress Default class). Here is an example – In header.php file – <nav id=”header-menu”> <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘walker’ => new Child_Wrap() ) ); ?> </nav> In my functions.php file – class Child_Wrap extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat(“\t”, $depth); … Read more

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