Dropdown list control in a post
Dropdown list control in a post
Dropdown list control in a post
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
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 ); }
You need to set selected argument for the wp_dropdown_users function. Do it like this: wp_dropdown_users( array( // … ‘selected’ => $user_id, // … ) ); Read documentation for wp_dropdown_users function
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
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
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
If you look at the source for the function, you can see that the arguments to the function are passed directly through to get_pages(). That function supports a post_status argument that can be an array of statuses. So to do what you want all you need to do is pass the post statuses you want … Read more
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.
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