Support

Account

Home Forums ACF PRO Relationship field ajax querying ALL results

Solved

Relationship field ajax querying ALL results

  • When using the relationship field with a custom post type that has over 2000 records, chrome crashes on me. Previously, this only loaded the first 10 or 20 records. Now it is trying to load all of them.

    I would attach the exact request and response headers, but I have about a three second window between receiving the xhr data in the inspector and the window crashing (Aw, Snap!)

    See screenshots of the network timeline, request headers, xhr results preview, and crash page.

    Note that the request has “1” for the max and an empty post_type. I have also gone through this with all other plugins disabled.

    As always, thanks for ACF! Best. Plugin. Ever.

    This is my field definition:

    if( function_exists('register_field_group') ):
    
    register_field_group(array (
    	'key' => 'group_53b59d1a3b7b0',
    	'title' => 'Recipe of the Week',
    	'fields' => array (
    		array (
    			'key' => 'field_534234632b9d0',
    			'label' => 'Date',
    			'name' => 'date',
    			'prefix' => '',
    			'type' => 'date_picker',
    			'instructions' => 'Select a Monday',
    			'required' => 1,
    			'conditional_logic' => 0,
    			'first_day' => 1,
    			'return_format' => 'Y-m-d',
    			'display_format' => 'l, F d, Y',
    		),
    		array (
    			'key' => 'field_534223efa8bfd',
    			'label' => 'Select Recipe of the Week',
    			'name' => 'recipe',
    			'prefix' => '',
    			'type' => 'relationship',
    			'instructions' => '',
    			'required' => 1,
    			'conditional_logic' => 0,
    			'post_type' => array (
    				0 => 'recipe',
    			),
    			'taxonomy' => '',
    			'filters' => array (
    				0 => 'search',
    			),
    			'elements' => array (
    				0 => 'featured_image',
    			),
    			'max' => 1,
    			'return_format' => 'id',
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'rotw',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'seamless',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => array (
    		0 => 'permalink',
    		1 => 'the_content',
    		2 => 'excerpt',
    		3 => 'custom_fields',
    		4 => 'discussion',
    		5 => 'comments',
    		6 => 'revisions',
    		7 => 'slug',
    		8 => 'author',
    		9 => 'format',
    		10 => 'featured_image',
    		11 => 'categories',
    		12 => 'tags',
    		13 => 'send-trackbacks',
    	),
    ));
    
    endif;
  • Hi @dotKev

    Thanks for the bug report. I’ll be adding in pagination in the next version!

    Cheers
    E

  • Thanks Elliot!

    Are you thinking about building actual pagination with numbers or “lazyloading” as you scroll to the bottom of a list? I think this is how ACF4 worked.

    My workaround for now is to immediately type something into the filter to get a smaller result set, but that won’t work in production for our client of course.

  • Hi @dotKev

    Just wanted to let you know I have successfully added in scrolling pagination to the relationship field!

    Do you have github access for ACF PRO? If not, what is your github username and I will add you to the repo so you can test out the new code

    Thanks
    E

  • This reply has been marked as private.
  • Hi @dotKev

    Thanks mate. I’ve just added you in.

    I’ve done a whole bunch of work on the pagination to make sure hierarchical post types display in the correct parent / child order, and also, the post type groups now appear in the order defined in the relationship field’s settings!

    Let me know what you think.

    Cheers
    E

  • Your solution worked perfectly, as usual.

    Thanks!

    .kev

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

You must be logged in to reply to this topic.