Problem:
Convert search field select to Select2 type field.
Solution:
One of the ways I see this possible is to make use of the select2 options.
https://select2.org/getting-started/basic-usage
However in order to use this we will need to enqueue the scripts for it.
Firstly you will need to add the following to your site in the Toolset custom code section at Toolset ->Settings-> Custom Code and activate it once added.
wp_register_style( 'select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css' ); wp_enqueue_style('select2'); wp_register_script( 'select2js', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', null, null, true ); wp_enqueue_script('select2js');
Secondly you will need to add the following to your view in the JS section.
jQuery(document).ready(function() { jQuery('#wpv_control_select_wpcf-artist-id').select2(); });
Where you will replace the "wpcf-artist-id" section of the select id with the full slug of your custom field. So the full format should look like.
#wpv_control_select_wpcf-{field-slug}
Relevant Documentation:
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 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 11 replies, has 2 voices.
Last updated by 3 years, 11 months ago.
Assisted by: Shane.