WordPress meta query not working
-
Hi
First of all thanks for your time making this plugin.
I have wordpress installed on a server using sqlite. Everything works fine except when I am doing the below meta query the WP_Query don’t return any posts. With tax_query there is no problem.
function rlp_get_posts($post_type = 'native', $num = 10, $offset = 0){ $args = array( 'posts_per_page' => $num, 'offset' => $offset, 'orderby' => 'id', 'order' => 'ASC', 'post_type' => $post_type, 'meta_query' => array( array( 'key' => 'rlp_native_age', 'value' => array( '18', '78' ), 'type' => 'numeric', 'compare' => 'BETWEEN' ) ) 'post_status' => 'publish', 'suppress_filters' => false ); return new WP_Query( $args ); }I tried to change the values in the array to int (because I take this value from a form as a string) with no luck.
On localhost with mysql everything works fine.Same content, same custom posts.
get_post_metaworks fine also.Thanks in advance.
-
Hi, laxmana
Nice catch! Thank you for reporting. I’ve got the malfunctioning myself. I’m afraid it’s not easy and will take time to fix this problem.
Will you change your meta query like below for the time being? This is only a workaround, but it will work as you expect.
'meta_query' => array( 'relation' => 'AND', array( 'key' => 'rlp_native_age', 'value' => 18, 'type' => 'numeric', 'compare' => '>=' ), array( 'key' => 'rlp_native_age', 'value' => 78, 'type' => 'numeric', 'compare' => '<=' ) )I’ll try fixing it so that you can use meta query with BETWEEN comparison.
Thank you.
Thank you!
It’s working as expected. I will be alert for the next commit 🙂
Thank you for your time and your effort.
Hi, laxmana
I committed the version 1.6.3 which includes the fix about meta query problem. I hope it will work fine with meta query with BETWEEN comparison.
Thanks.
Hi
I just noticed your new commit and your post. I tested and everything is working fine.
Thanks a lot!
The topic ‘WordPress meta query not working’ is closed to new replies.