WP Query multiple select form – meta_query help
WP Query multiple select form – meta_query help
WP Query multiple select form – meta_query help
You have two problems. First need to global $wpdb;. Then you are using the_title() and the_permalink() both of which automatically echo out a value. So you need to switch them to get_the_title() and get_permalink(). function get_post_by_alphabet($the_char){ global $wpdb; $first_char = $the_char; $postids=$wpdb->get_col($wpdb->prepare(” SELECT ID FROM $wpdb->posts WHERE SUBSTR($wpdb->posts.post_title,1,1) = %s ORDER BY $wpdb->posts.post_title”,$first_char)); if ($postids) … Read more
AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
Pass your information through prepare as in this example from the Codex: $metakey = “Harriet’s Adages”; $metavalue = “WordPress’ database interface is like Sunday Morning: Easy.”; $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) “, array( 10, $metakey, $metavalue ) ) ); Your array should have … Read more
wordpress option page data from select form is not saving to database
First of all, You don’t have to add ‘form’ html tag in the metabox. You missed to pass the ‘$post’ parameter to the function ‘display_post_options’ and you used selected() function wrong too. Here is the code after I updated it. function display_post_options( $post){ wp_nonce_field( basename( __FILE__ ), ‘post_options_nonce’ ); $post_options_select_value = get_post_meta($post->ID,’post_options_select’,true); ?> Choose Your … Read more
Here’s the working answer for future reference. <p> <label for=”<?php echo $this->get_field_id(‘select’); ?>”><?php _e(‘Choose A Page:’, ‘check_avail_widget’); ?></label> <select name=”<?php echo $this->get_field_name(‘select’); ?>” id=”<?php echo $this->get_field_id(‘select’); ?>” class=”widefat”> <option value=”Select A Page”> <?php echo esc_attr( __(‘Select A Page’) ); ?> </option> <?php $pages = get_pages(); foreach ($pages as $page) { echo ‘<option value=”‘.get_page_link($page->ID).'” id=”‘ . … Read more
Ajax Form data is not posted back to the get_results()
There is no specific issue with retrieving null values from the database. They will come back as the PHP NULL value. WordPress uses either the function mysqli_fetch_object or mysql_fetch_object to retrieve results from the database. https://php.net/manual/en/function.mysql-fetch-object.php https://php.net/manual/en/mysqli-result.fetch-object.php According to those respective pages: Note: This function sets NULL fields to the PHP NULL value. Are you … Read more
Instead of a sql query, I recommend to do it in wordpress way: $args = array( ‘numberposts’ => 3, ‘offset’ => 0, ‘category’ => put_your_category_id_here, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘suppress_filters’ => true ); $request = wp_get_recent_posts( $args, ARRAY_A ); Reference : WordPress Update : here is the … Read more