Skip to content

How to change order of the option on the Search Form Checkbox Popup

Control which options a search-form checkbox popup offers and in what order, using one filter in your child theme instead of the full alphabetical list of terms.

1 minute read

By default a checkbox field in the search form lists every term of its taxonomy. This article shows how to reorder those options, or narrow the popup down to just the ones you want.

Vehica inventory page with the Features checkbox popup open, showing a long scrollable list of feature checkboxes with a result count after each one, a “Clear all Features” link and an orange Done button
Where this code goes
The snippet belongs in the functions.php file of your child theme — see how to use a child theme and how to add code that survives theme updates.
functions.php
add_filter('vehica/search/field/TAXONOMYID/terms', function() {
    return [
        \Vehica\Model\Term\Term::getById(TAGID1),
        \Vehica\Model\Term\Term::getById(TAGID2),
    ];
});

There are two things to fill in:

  • TAXONOMYID — the id of the field whose popup you are changing
  • TAGID — the id of each term you want to keep, listed in the order you want them shown

Filled in, it looks like this:

functions.php
add_filter('vehica/search/field/6670/terms', function() {
    return [
        \Vehica\Model\Term\Term::getById(2096),
        \Vehica\Model\Term\Term::getById(2106),
    ];
});

Find the TAXONOMYID

Go to Vehica Panel > Custom Fields, open the field for editing, and read the number from the page address.

Vehica Panel Custom Fields list (Year, Offer Type, Drive Type, Transmission, Fuel Type, Mileage, Engine Size, Cylinders, Color, Doors, Features), with green arrows on Custom Fields in the panel menu and on the EDIT button of the Features row
Settings screen of the Features field, field type Taxonomy, with Name and Slug set to Features; a green arrow points at the browser address bar, where the URL contains page=vehica_6670

Here the taxonomy id is 6670.

Find the TAGID

Open the term itself in the WordPress admin and read the tag_ID value from the page address.

WordPress Features taxonomy screen: Add New Features form on the left, term list on the right (360-degree camera, Blind spot alert, Bluetooth, Cooled seats, Keyless start), green arrows on Features in the menu and on the Edit link under Keyless start
Edit Features screen for the term Keyless start with the slug keyless-start; a green arrow points at the browser address bar, where the URL contains tag_ID=2096

Here the term id is 2096.

The result

With those two ids in place, the snippet becomes:

functions.php
add_filter('vehica/search/field/6670/terms', function() {
    return [
        \Vehica\Model\Term\Term::getById(2096),
        \Vehica\Model\Term\Term::getById(2106),
    ];
});

The popup is now limited to the terms you listed:

The Features popup on the inventory page now showing only two checkboxes, Blind spot alert and Keyless start, with the page reporting 12 results

Ask the people who build Vehica

We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.

Was this guide helpful?