Get data from dropdown and update page

How about this: <?php $arr = [“Cat”, “Dog”, “Cow” ]; if( $_POST[‘animal’]){ $animal=$_POST[‘animal’]; echo $animal; } ?> <form name=”f” id=”a” method=”post” action=””> <select id=”animal” name=”animal” onchange=”this.form.submit()” > <option value=”0″>–Select Animal–</option> <?php foreach ($arr as $a){ if($a == $animal){ echo “<option value=”{$a}” selected >$a</option>”; }else{ echo “<option value=”{$a}” >$a</option>”; } } ?> </select> </form> Note you … Read more

Getting the dropdown menu to redirect to different pages?

ok so i figured it out… i changed the select to <select onChange=”this.form.submit()” name=”page_id”{$id} class=”$class”> so that name passed in the url gets changed to ?page_id which i want since that is the format i am using (default wordpress format), and then i called my page_by_title function (btw i had to change the name of … Read more

Search results sorted by post types

You can use filter posts_clauses For example: add_filter( ‘posts_clauses’, ‘post_query_order’, 20, 1 ); function post_query_order( $pieces ) { global $wpdb; $pieces[‘orderby’] = $wpdb->prefix.’posts.post_type ASC’; return $pieces; }

Archive dropdown styling not applied

You’re targeting cd-dropdown with a class indicator (the period), the cd-dropdown is an ID and should therefore be targeted with the ID selector (a hashtag). #cd-dropdown > span, #cd-dropdown ul li:nth-last-child(-n+3) span { box-shadow: 0 1px 1px rgba(0,0,0,0.1); }

wp_dropdown_pages default value

I would suggest, that you switch from “URl query argument” style to arrays. This is a “feature” that is more a left over on some functions that is only available for backwards compatibility reasons than anything else. Here’s a reworked version of your current arguments: wp_dropdown_pages( array( ‘title_li’ => ”, ‘depth’ => TRUE, // originally: … Read more

How to retain the values from dropdown category lists after wrong form submission?

Like Ash was saying, something like this using $_REQUEST or $_POST will do it. <?php $args[‘exclude’] = “12,20”; // omit these two categories $categories = get_categories($args); ?> <select class=”selectpicker btn-block” name=”coupon_cat” id=”category”> <option value=””>Категори Сонгох</option> <!– if nothing else is selected, this will be selected automatically –> <?php foreach($categories as $category): ?> <?php $selected = … 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

How to get a list of taxonomy terms which are being used only within certain post types?

I’m not a programmer so there’s probably a far more efficient/correct way of doing this. Put this in functions.php or a custom plugin: function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb->get_results( “SELECT t.*, COUNT(*) from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN $wpdb->term_relationships AS r … Read more