79785421

Date: 2025-10-08 11:55:48
Score: 1
Natty:
Report link

Thanks, Snuffy! That really did help!

When you create a taxonomy field in ACF and set the “Return Value” to “Term ID,” ACF doesn’t store the ID as an integer, but as a serialized array, even if you allow only one term. Like this a:1:{i:0;s:2:"20";}

So, you have to compare value of the field to a string value of the serialized array. And fixed request in my case looks like this:

$query = new WP_Query( [
    'post_type' => 'photo',
    'meta_query' => [
    [
        'key' => 'year_start',
        'value' => 'a:1:{i:0;s:2:"20";}',
        'compare' => '='
    ]
    ]
]);
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Griox Angle