Home › Forums › ACF PRO › Repeater Fields and pre_get_posts › Reply To: Repeater Fields and pre_get_posts
You need to add some more detailed checking to make sure you’re modifying the correct queries because your pre_get_posts filter will be called on every query that WP performs. To do this you need to look at the values in the current query and somehow narrow it down to only the query you want to modify. You may also need to look at the specific page that’s being loaded, for example, on the front page you might do
if (is_front_page() && $query->is_paged ) {
checking that you’re only modifying a posts query would look something like
if (!empty($query->query_vars['post_type']) &&
$query->query_vars['post_type'] == 'post') {
and you probably always want to do this because you really never want to run a pre_get_posts filter in the admin, or almost never.
if (is_admin()) {
return;
}
I’m not exactly sure what you need to do in your case, you’re going to need to figure that out.
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.