Skip Navigation

[Resolved] Fields with dropdowns for related posts only show 10 options

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'm now developing the form and included the "Countries-Contacts" relationship field. The problem is that in front-end the dropdown only shows 10 countries (and not in alphabetic order). How can I have a dropdown to show all 211 countries I have?

Solution:

You can try the cred_select2_ajax_get_potential_relationship_parents_query_limit filter hook, like this:

https://toolset.com/forums/topic/fields-with-dropdowns-for-related-posts-only-show-10-options/#post-2073029

Relevant Documentation:

This support ticket is created 3 years, 11 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by Luo Yang 3 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2072729

I'm setting up a form with a relationship between two post types. It's a contact form and I want to include a field to show all countries in a dropdown, so that users inform me which countries are they from. I've created a CPT for countries and connected with another CPT I've created for Contacts. I'm now developing the form and included the "Countries-Contacts" relationship field. The problem is that in front-end the dropdown only shows 10 countries (and not in alphabetic order). How can I have a dropdown to show all 211 countries I have?

I've checked support ticket "https://toolset.com/forums/topic/post-relationship-field-with-use_select2always-only-has-ten-results/#post-1240194" but since I have no experience with codingit was of no help to me... I don't really know where to include the coding suggested in the ticket.

Thank you in advance.

#2073029
orderby.JPG

Hello,

You can put that custom codes into your theme file "functions.php", for example:

add_filter('cred_select2_ajax_get_potential_relationship_parents_query_limit', function($limit){
  return 200;
});

For the "alphabetic order" problem, please edit the post form you mentioned above, find and edit the relationship field, make sure you are using option "Order options by title" "Ascending", see my screenshot orderby.JPG

#2074695

Hello Luo,
I'm sorry but I have no coding experience. Where exactly should I put the custom code you're suggesting? Where can I find the theme file "functions.php"? Is it in the Form Editor - expert mode? Could you please send me a screenshot for this? Thank you.

#2075393

Please provide a test site with the same problem, also point out the problem page URLs, I can setup a demo for you

#2078923

Thanks for the details, I have done below modifications in your website:
1) Edit the post form "Info Request":
hidden link
In form content area, switch to expert mode, change the relationship field shortcode to:
[cred_field field='@country-contact.parent' class='form-control' output='bootstrap' select_text='--- not set ---' order='title' ordering='asc']

More help:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_form

2) Edit theme file "functions.php":
hidden link
line 34~36, add below lines:

add_filter('cred_select2_ajax_get_potential_relationship_parents_query_limit', function($limit){
  return 300;
});

Please check if it is fixed, thanks

#2079131

Hello Luo, it's fixed. Many thanks for your support!

#2079947

Feel free to create new ticket for other new questions