[Resolved] Distance feature: Display in one line and only show km?
This thread is resolved. Here is a description of the problem and solution.
Problem: I would like to display the distance filter fields for a custom search View on a single line, in horizontal format. I would also like to hide the distance unit select field and show only the unit text 'km' instead of the select field and options for other units.
Solution: Be sure the distance filter block is added to the Block Editor in a grid block, a container, or other block element set to the full width you want to cover with this row of filters. Add custom CSS to resize the inputs as needed, and adjust the styles for a custom solution.
This support ticket is created 3 years, 6 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.
Hello, I am not seeing the "distance-search-block" CSS class added to the distance filter as shown in the other ticket: https://nimb.ws/gLpEfO
That's the first thing I would check in the View editor screen. If it's still not working as expected after adding the required CSS class to the filter block, I may need to log in and take a closer look. Please provide login credentials in the private reply fields here.
You should edit the page containing the View. I believe it is here: hidden link
In the Block Editor, you should select the Custom Search Filter block that contains the distance filter. In the sidebar, open the Advanced panel and add the CSS class in the CSS Classes field. Type the classname and then type Enter or Return to set the class. Then save the Page.
I am attaching another screenshot here for you. You can see the distance filter block selected, and the CSS Class input field in the Advanced sidebar panel.
I see you have added the CSS for this particular problem but it didn't resolve my issue.
That is odd, because if I remember correctly this CSS code was already added when I checked the site on May 9...I do not recall adding this CSS myself. The CSS is added in the Customizer's Additional CSS panel, but I do not remember adding it myself. I remember seeing the CSS but not seeing the classname added to the filter, so that is why I recommended adding the CSS classname next. Anyway, not a big deal but it's strange that you are under the impression I added the code.
It looks like the Submit and Cancel buttons were in the same grid row as the distance filter elements. That prevented the inputs from extending full-width. I moved the distance filter block above the grid containing the submit and cancel buttons, and removed the 220px top-margin from both of those buttons. I hope that's okay, I assume this is what you want to achieve here. Let me know if I misunderstood, but I think you need the full-width here to display all the distance filter elements in one line.
Here are the changes I made in the Customizer's CSS panel. The main problems were the width of the distance number input and the display mode of the nested .form-group element. I also hid the "km" select field since the other ticket discusses adding the text with JavaScript.