Skip Navigation

[Resolved] Dropdown only shows ten, many:many relationship form

This support ticket is created 2 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by sarahK-2 2 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2351419

I have a many:many relationship form with about 30 options in the dropdown. One side of the relationship is known, the other is being selected. It seems the default is to limit options to ten. I would like to show all 30.

I followed this documentation
https://toolset.com/forums/topic/post-relationship-field-with-use_select2always-only-has-ten-results/

and added the following to my theme functions.php
add_filter('cred_select2_ajax_get_potential_relationship_parents_query_limit', function($limit){
return 30;
});

It did not work. Thanks in advance for any help you can give me.

#2351459

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There is no filter available to override the number of options displayed by post relationship form's select2 dropdown as it seems that its been hardcoded.

The file path would be within the Toolset common:

plugins\cred-frontend-editor\vendor\toolset\toolset-common\inc\autoloaded\ajax_handler\select2_suggest_posts_by_post_type.php

With above file you will see the following code where as you can see its hardcoded to 15:

$posts = $this->query_posts(
			$post_type,
			toolset_getpost( 'author', null ),
			$orderby,
			toolset_getpost( 'order', 'DESC', array( 'ASC', 'DESC' ) ),
			0,
			15
		);

Its your choice if you want to change it and see if that helps but when you update plugins, you will require to change that limit again to your desired number.

#2355567

Not sure I want to do that, I wish there was a better way. Thank you for the information, though 🙂