Querying with WP query using meta key price

‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’. Try to use like this : $args = array ( ‘post_type’ => ‘product’, ‘post__in’ => $post_ids, ‘posts_per_page’ => -1, ‘order’ => … Read more

WP_Query custom order and pagination

You want to orderby ‘date’ not by ‘meta_value_num’ because it is to order numerically. So if you were ordering items by their price, then you would want to use ‘meta_value_num’. The meta_key ‘news_date’ is most likely in date format. You should also cast the meta_value to DATE using ‘meta_type’ => ‘DATE’. $args = array( ‘post_type’ … Read more

WordPress Insert not working with ajax

Your AJAX callback method should be outputting something followed by a die() statement. function wp_insert() { ..your code echo $whatever_your_results_are; // die(); } I would also recommend against prefixing your custom methods with wp_. That should be reserved for WordPress and will cause confusion to other developers – and probably you 6 months down the … Read more

Filtering custom posts by custom fields (ACF) [closed]

Ok, so after deeper research I’ve found out that values of some custom fields created by ACF are stored in MySQL database with some additional information like a:5:{i:0;s:6:”Aerial”;i:1;s:6:”Nature”;i:2;s:4:”Nude”;i:3;s:6:”People”;i:4;s:8:‌​”Wildlife”;}. This happens when a custom field can store multiple values (like chechboxes). So I’ve edited part of my query from this: if( !empty($_GET[‘theme’]) ) { $contestTheme = … Read more