Widget & storing a Select box choice

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

Selecting NULL value from the database

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

Add category selection to function request

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

Custom Select Query pagination not working properly

I found solution. Grouping duplicated posts by ID. Just add this code to select query: GROUP BY wp_posts.ID Whole code (maybe it will help someone – not many examples of working pagination with select query around the internet :)): <?php global $wpdb; $date = date(“Y-m-d”); $querystr = ” SELECT * FROM wp_posts JOIN wp_ftcalendar_events ON … Read more

WordPress Multiple Taxonomy Query

Perhaps you can add a hidden field to the HTML which will pass the ‘relation’ => ‘OR’. <input type=”hidden” name=”tax_query[relation]” value=”OR”> <select name=”tax_query[][country]” multiple> <option value=”united-kingdom”>United Kingdom</option> <option value=”ireland”>Ireland</option> </select> <select name=”tax_query[][type]” multiple> <option value=”director”>Director</option> <option value=”partner”>Partner</option> </select> Which translates to: tax_query[relation]=OR&tax_query[][country]=united-kingdom&tax_query[][type]=director Array ( [tax_query] => Array ( [relation] => OR [0] => Array ( … Read more

How to Display image from Menu Image in Walker Dropdown Select Menu

It’s stored in metadata, there are four meta fields: _thumbnail_id and _thumbnail_hover_id – store attachment ID, _menu_item_image_size – store selected image size, _menu_item_image_title_position – store label position, but you can get stored values from this properties: $item->thumbnail_id, $item->thumbnail_hover_id, $item->image_size, $item->title_position. Check the menu_image_nav_menu_item_filter() function in menu-image.php