Problem:
I am having an issue with adding default text to multi-select taxonomy filters in Toolset, as the default_label only works for select taxonomy filters.
Solution:
To add a value-less option with the desired text to the multi-select input, use the following JavaScript code:
document.addEventListener("DOMContentLoaded", function() { // Get the select element const selectElement = document.querySelector('select[name="wpv-offering[]"]'); // Create a new option element const defaultOption = document.createElement('option'); defaultOption.value = 'any'; defaultOption.text = 'Any'; // Set the new option as the default selected option defaultOption.selected = true; // Add the new option to the beginning of the select element selectElement.insertBefore(defaultOption, selectElement.firstChild); });
This code waits for the DOM content to be loaded, gets the select element, creates a new option element, sets it as the default selected option, and adds it to the beginning of the select element.
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
This topic contains 6 respuestas, has 3 mensajes.
Last updated by daveG-7 hace 1 año.
Assisted by: Christopher Amirian.