Here's a question I've been trying to solve all day:
I added a WP Query
that would show posts from a category that the admin chooses with a custom field. The post is a custom post type called "Testimonials", and the category is a custom category called "Testimonial Categories". The admin can select multiple categories, and all the relevant testimonials should appear on the page.
The code mostly works, but 1 testimonial is missing. Even stranger, the missing testimonial is different between staging and production sites (the content is exactly the same).
It seems that when a field gets updated on the missing testimonial, that testimonial makes it to the page. But a different testimonial goes missing. Also very strange behavior.
Here's the WP Query
:
@php
$cats = get_sub_field('reviews_category'); // gets the custom field categories
$args = array(
'post_type' => 'testimonials',
'numberposts' => -1,
'order' => 'DESC',
'orderby' => 'meta_value',
'meta_key' => 'date',
'tax_query' => array(
array(
'taxonomy' => 'testimonial_categories',
'field' => 'term_id',
'terms' => $cats
),
)
);
$query = new WP_Query($args);
@endphp
Thanks in advance for your help. Let me know if I am missing information that can be useful.
numberposts
is not a valid parameter. You need to useposts_per_page
.