Support

Account

Home Forums Front-end Issues relationship field – lazy loading infinite loop

Helping

relationship field – lazy loading infinite loop

  • Hi there,

    I’m applying a filter to my relationship field, so that it only shows pages with a certain template applied. It works quite well!

    below is the argument I build with my function.`$args = array(
    'order' => 'ASC',
    'orderby' => 'title',
    'post_status' => 'published',
    'post_type' => 'page',
    'meta_query' => array(
    array(
    'key' => '_wp_page_template',
    'value' => 'my page template name.php',
    'compare' => 'LIKE'
    )
    )
    );`

    The filter works 99% correctly. The only thing is a quick with the interface. The list that appears on the left hand size (below the search box), has a lazy loading thing. Each time it loads, it loads the exact same set of pages. E.g 8 pages are listed initially. I scroll to the bottom, the lazy loading kicks in and an additional set of 8 pages (the same 8 as previously) are added to the list.

    As long as I keep scrolling the list keeps repeating itself.

    This doesn’t seem to effect the selection or saving of the data, but it is confusing my client!

    Below is the code I use to add the filter

    add_filter('acf/fields/relationship/query/name=my_field_name', 'my_acf_relationship_filter_query', 10, 3);
    

    I’m using ACF v4.2.2 on WP v3.5.2

  • Hi @charlie

    Your code is completely overriding the $args array and is destroying the paged attribute. You need to keep this attribute for the AJAX to know when to stop.

    Perhaps you could look at the $args array, and only edit what you need to instead of overriding it?

    Thanks
    E

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘relationship field – lazy loading infinite loop’ is closed to new replies.