Home › Forums › General Issues › Numberposts & Meta Query Not Working › Reply To: Numberposts & Meta Query Not Working
To clarify further, the whole code snippet is as follows:
$relatedCat = get_field('service_related_industry');
$args = array (
'posts_per_page' => 3,
'post_type' => 'case_study',
'meta_query' => array(
array(
'key' => 'cs_industry',
'value' => $relatedCat,
'compare' => 'LIKE',
)
),
'orderby' => 'DESC',
);
if (!$relatedCat) {
$relatedCat = get_field('service_related_category');
unset ($args);
$args = array (
'posts_per_page' => 3,
'cat' => $relatedCat,
'orderby' => 'DESC',
);
}
If I comment out the first line, the IF statement works perfectly, and in fact it also adjusts the number of posts correctly. So, I reckon the problem is in the way the first field (service_related_industry) is being handled. But I can’t quite figure out what’s going wrong.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.