I am working on a magazine website that has a large amount of posts, submissions, etc. There is about 60K+ posts/submissions on the site right now. I don't know when it happened specifically, but today I noticed that my featured posts section has stopped working.
The functionality is simple. When editing a post there is a checkbox on the side what when you check it, an ACF meta key by the name "featured_post" becomes true. Then in the featured post section, my WP Query runs:
$args = [
'numberposts' => 1,
"posts_per_page" => 1,
'post_type' => 'post',
'meta_key' => 'featured_post',
'meta_value' => true
];
$the_query = new WP_Query($args);
Like I said, this WAS working and now it isn't returning anything. I commented out the meta_key and meta_value arguments and it returns posts. I have also tried adding 'meta_compare' => 'LIKE' / '=' as a last argument and that did not work.
I have tried rewriting the meta as a meta_query:
'meta_query' => array(
array(
'key' => 'featured_post',
'value' => true
)
)
I've also tried including a compare argument after the 'value' argument too:
'compare' => 'LIKE'
and also tried
'compare' => '='
I've also tried using square brackets instead of calling array(). And tried calling the meta_value as 1 and '1' instead of true.
And I have also tried wp_reset_postdata(), wp_reset_query(), and even remove_all_actions('pre_get_posts') at the same time, different times, and a mix.
I have also looked in the database and I get see the meta_value in the postmeta table.
I am absolutely at a loss as to why this stopped working. Any help is appreciated.
WP_Query
generates and add to your question: wordpress.stackexchange.com/questions/4809/….