Home › Forums › General Issues › Solved issue, but would like an explanation › Reply To: Solved issue, but would like an explanation
The reason is that your code appears to be modifying every query, your code will also modify any query made by acf or any other plugin or theme code. What you need to do is be more specific about what query you want to alter.
// only modify the main query
if ($query->is_main_query()) {
// modify query
}
// only modify queries on a specific post type
if (isset($query->query_vars['post_type']) &&
$query->query_vars['post_type'] == 'post-type-slug') {
// modify query
}
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.