Help with a get_categories () drop down menu – I want it to show in heirachial form

wp_dropdown_categories has a hierarchical and depth options available. $args = array( ‘show_option_all’ => ‘All Tshirt Categories’, ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ‘hide_empty’ => 1, ‘child_of’ => 0, ‘hierarchical’ => 1, ‘depth’ => 1, ‘taxonomy’ => ‘tshirt_categories’, ‘hide_if_empty’ => false ); ?> <h2>By Category</h2> <form action=”<?php bloginfo(‘url’); ?>” method=”get”> <div> <?php wp_dropdown_categories($args); ?> <input type=”submit” … Read more

working with result of wp_dropdown_pages()

Not sure what your trying to do with the custom field but you can create your own drop down select using the get_pages() function which returns an array of pages similar to the get_posts() function. $pages = get_pages(); foreach( $pages as $page ) { echo get_post_meta( $page->ID, ‘your_meta_key’, true ); }

Link to subpages on the same page

get_children is the most straightforward way to get “attachments, revisions, or sub-Pages”. So… $children = get_children(array(‘post_parent’=>$post->ID)); if (!empty($children)) { foreach ($children as $child) { echo ‘<div id=”child-‘.$child->ID.'” >’; // content formatted however you want echo ‘</div>’; } See the Codex page for further parameters that you might need. I don’t know how you’ve constructed your … Read more

How to populate a dropdown menu with option selected?

Use the selected HTML attribute. See w3schools docs. In your foreach loop, check if the current category matches the current iteration, and add the selected attribute to that option element. You are already getting the ID of each term, so you’ll need to also get the current category ID so you can check against it. … Read more

create drop down menu

What you are searching for its a submenu page. Try with this: add_submenu_page( ‘my-top-level-slug’, ‘My Custom Submenu Page’, ‘My Custom Submenu Page’, ‘manage_options’, ‘my-secondary-slug’ ); you can find more info here An example with your code: function my_plugins() { add_menu_page( ‘My Plugin’, ‘My Plugin’, ‘manage_options’, ‘visitor-counter-by-funcion’, //THIS IS THE SLUG YOU NEED TO USE IN … Read more

Bootstrap drop down Navigation Menu in WordPress

You will want to extend the Walker_Nav_Menu class. This allows you to “walk” through the various states of a navigation menu. One of the first google searches I did for the term Walker_Nav_Menu led me to this Github repo with a class already built. wp-bootstrap-navwalker.

pages meta box – get_categories dropdown

if you are using it in a metabox then you really don’t need this part: onchange=”document.location.href=this.options[this.selectedIndex].value;” So change the select fields to: <select name=”event-dropdown”> <option value=””><?php echo esc_attr(__(‘Select Event’)); ?></option> <?php //get saved data $saved_cat = get_post_meta($post_id,’event-dropdown’,true); $categories= get_categories(‘child_of=10’); $select_options=””; foreach ($categories as $category) { $option = ‘<option value=”‘.$category->cat_ID.'”>’; $option .= $category->cat_name; $option .= ‘</option>’; … Read more

Get the selected option from drop down list

I have been searching and trying many suggestions I found, but until now nothing seems to be doing the trick. If possible I want to get this done in php (value needs to be in $ to build db-query). Your course selection drop-down must be enclosed within a <form> tag with a submit button, like … Read more