Select From wpdb – Author/User Directory page

You’re probably better off to use get_users which returns an array of <?php // get all users, regardless of roll. If you do need to restrict by // role you can use the `role` argument: get_users(array(‘role’ => ‘author’)); $uses = get_users(array(‘orderby’ => ‘nicename’)); foreach ($users as $user) { // do stuff with $user, will have … Read more

Add a select-option to the default widgets

The default widgets do not offer any hooks for that. You have to replace the default widget and add your field to the new class. The other option would be using JavaScript to insert the field, and a filter for ‘update_option_widget_’ . $widget->id_base to save the value. I think the separate class is the cleaner … Read more

Select post from dropdown and add query args not working

Rename your <select> to something other than page_id. The problem is that page_id is already taken (and handled) by WordPress (as query var). This should do, for example: <?php if (isset($_GET[‘editevent’]) && true == $_GET[‘editevent’]) echo ‘Post ID: ‘.$_GET[‘my_page_id’]; ?> <form method=”GET” action=”#”> <select name=”my_page_id” id=”my_page_id” onchange=”this.form.submit()”> <?php $args = array( ‘posts_per_page’ => -1, ‘post_type’ … Read more

Widget select option not saving

This line $type = isset( $instance[‘type’] ); will set $type to either true or false which never matches the string you check for later: foreach ($types as $option) { echo ‘<option value=”‘ . $option . ‘” id=”‘ . $option . ‘”‘, $type == $option ? ‘ selected=”selected”‘ : ”, ‘>’, $option, ‘</option>’; } You need … Read more

Help me SELECT thumbnail from SQL and use

You do not need to be messing with the database connection. WordPress provide a database object called $wpdb. It is not really clear what you are doing. Your title reads “help me select thumb”, but your code is actually pulling a lot of different post statuses, not thumbnails. In fact, your code does not have … Read more

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

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