Custom Taxonomy Select Menu: Setting default option value?

Simply add an extra line before your for loop. For example: function get_color_dropdown($taxonomies, $args){ $myterms = get_terms($taxonomies, $args); $output =”<select onChange=”window.location.href=this.value”>”; $output .= “<option value=”default”>Shop by Color –></option>”; foreach($myterms as $term){ $root_url = get_bloginfo(‘url’); $term_taxonomy=$term->taxonomy; $term_slug=$term->slug; $term_name =$term->name; $link = $root_url.”https://wordpress.stackexchange.com/”.$term_taxonomy.”https://wordpress.stackexchange.com/”.$term_slug; $output .=”<option value=””.$link.””>”.$term_name.”</option>”; } $output .=”</select>”; return $output; } $taxonomies = array(‘pa_color’); $args = … Read more

Making jQuery .change() event persistent after widget save

The form reloads itself each time you save returning to the initial state where all are shown. What you can do is this: // Getting the value of the selected field var my_select_value = $(‘#widgets-right select.my-select’).val(); // If there’s no value selected, hide everything. if(my_select_value == 0){ $(‘.widget-test .row’).hide(); } // Otherwise, show the specific … Read more

Custom select query two tables by a meta key

First of all you are trying to combine both of the tables by post_parent. $wpdb->posts.post_parent = $wpdb->ftcalendar_events.post_parent I guess data in the ftcalendar_events has children of posts table, try $wpdb->posts.ID = $wpdb->ftcalendar_events.post_parent Also you can try joining tables: SELECT * FROM $wpdb->posts JOIN $wpdb->ftcalendar_events ON $wpdb->posts.ID = $wpdb->ftcalendar_events.post_parent WHERE $wpdb->posts.post_status=”publish” AND $wpdb->posts.post_type=”post” ORDER BY $wpdb->posts.post_date … Read more

How to call custom jQuery plugins into the customizer controls

First, in order to enqueue JS in the customizer controls, you need to use the customize_controls_enqueue_scripts action. This is different than the action used to enqueue scripts into the customizer preview, which is what themes normally do via customize_preview_init or wp_enqueue_scripts. So in your snippet above, replace customize_preview_init with customize_controls_enqueue_scripts. Secondly, in order to extend … Read more

Retrieve select tag custom values from array and display them in current page with wp_query?

@Nick83, While I’m not trying to make the answer overly complicated, in order to do what you are attempting to do correctly I believe you’ll need to call WordPress via Ajax. My recommendation is the following: Create two ajax calls. The first gets the prices (without duplicates). The second takes whichever price the user chose … Read more

Check if a value exists in database table

Replace this: $result = $wpdb->get_row(“SELECT * FROM wp44_predefined_address WHERE ‘UPPER(Address1)’ LIKE ‘UPPER(%s)'”, $myinput); with this: (just choose the appropriate $like based on your requirements) // Properly generate the LIKE query. $like=”%” . $wpdb->esc_like( $myinput ) . ‘%’; // e.g. ‘%input%’ //$like=”%” . $wpdb->esc_like( $myinput ); // e.g. ‘%input’ //$like = $wpdb->esc_like( $myinput ) . ‘%’; … Read more