Jakson
1
Hey there,
Got this Query that has a Meta Query - looks for the Meta Key (static) and the Meta Value dynamically (WordPress > Post ID)
Thing is it doesn’t seem to wok using the dynamic method - ignores the Meta Query completely and returns straight list of latest posts
BUT - when I change to Meta Value to “Static” and manually type in a Post ID I get the correct set of posts listed.
Any pointers here guys?
cheers!
<?php
// The Arguments
$args = array (
'post_type' =>
array (
0 => 'post',
),
'posts_per_page' => 2,
'ignore_sticky_posts' => true,
'meta_query' =>
array (
0 =>
array (
'key' => 'database_mentions',
'value' => '""',
'compare' => 'LIKE',
'type' => 'CHAR',
'title' => 'database_mentions',
),
),
'orderby' => 'date',
'order' => 'DESC',
);
// The Query
$the_query = new WP_Query( $args );
Jonas
2
Could you describe in more detail what it is exactly that you want to achieve? So what posts with what characteristics should be displayed where.
Jakson
3
As per the screen shot / generated Cwicly code @Jonas :
Using a static Post ID works, using dynamic to pull in Post ID in the query does not.
Jonas
4
Ok, maybe a bit too complex for me – I’m pretty new here, sorry.
Jakson
5
no worries @Jonas - appreciate your attention
Louis
6
Hi @Jakson,
Thanks for posting this and sorry for the trouble.
I can confirm that there is an issue when trying to compare with an integer value in this specific case as the Post ID is being returned as a string.
We’ll have this fixed in the next update.
Apologies once again for the inconvenience.
Moving to bugs.
Louis
7
Hello @Jakson,
This should be addressed in 1.2.9.4.
If you sill encounter trouble with this, please let me know by replying to this thread.
Cheers,
Jakson
8
Awesome, thanks @Louis - will test and let you know
Jakson
9
Yep, all purring along now @Louis - thanks!