Support

Account

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.