Order admin post list table by meta field, and have posts without the meta field always be at the end of the list
Order admin post list table by meta field, and have posts without the meta field always be at the end of the list
Order admin post list table by meta field, and have posts without the meta field always be at the end of the list
Issue with user meta_query
Use get_the_title to get the title. the_title is for when you want to output directly to the browser.
This isn’t possible with WP_Query. To achieve your goal multiple queries are necessary, one for each country, with the results fetched separately then combined in PHP manually. You also can’t use meta_query to sort, meta_query is for filtering/searching post meta, which is very expensive and gets slower as your meta table gets larger. Post meta … Read more
Figured it out from a comment made here. The fix was to change this: ‘value’ => $p_specialty, … to this: ‘value’ => ‘”‘.$p_specialty.'”‘, … and leave the LIKE compare as-is. Just for more info, I had also tried serializing that value but that didn’t work.
So, I actually fixed the issue by reversing the order of the OR conditions. If anyone knows why this fixed it, I’d love to know. $next_event = get_posts( array( ‘post_type’ => ‘event’, ‘post_status’ => ‘publish’, ‘numberposts’ => 1, ‘fields’ => ‘ids’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_post_date_year’, ‘value’ => $year, ‘compare’ … Read more
Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
How do i create a custom post query when the meta value is an array?
Probably what you wnat do is : update_post_meta( $post_id, $meta_key, serialize($meta_value)); or to create : add_post_meta( $post_id, $meta_key, serialize($meta_value)); or to delete : delete_post_meta( $post_id, $meta_key);
Assuming that you want to get posts with that meta key, regardless of content, and order by that meta value, you would need to set two properties. meta_query orderby So the code, based of your question would be like this // Custom query to order ‘recommended reading’ posts by populatrity add_action(‘elementor/query/my_custom_filter’, function ($query) { if … Read more