custom taxonomy – Best approach of implementing multi-select/checkboxes for taxonomies?

Question

I am working on modifying how multi-select is done in a list in a custom wordpress plugin instead of using the default method of holding ctrl and clicking. The point of the plugin is to be able to upload files to a website, and then select metadata to assign to that file. A friend recommended I look into using ACF for options, such as having each metadata have a check box next to it. Is that best practice? What other alternatives would be preferable?

It’s my understanding that the current way to display the taxonomies used as metadata options are displayed in the most basic way on WordPress. Here is the code currently used to pull and display the metadata:

<!-- Section metadata form component -->
<div class="col-6">
    <label for="section_metadata" class="form-label">Select Section Metadata</label>
    <select class="form-select" name="section_metadata[]" multiple>

        <?php

        // Get metadate selections from wpum-categories that are added by Site Admin

        $section_metadata = get_terms(array(
            'taxonomy' => 'wpum-category',
            'hide_empty' => false,
        ));

        //print_r($section_metadata);

        foreach ($section_metadata as $value) {
            echo '<option value="' . $value->term_taxonomy_id . '">' . $value->name . '</option>';
        }

        ?>

    </select>
</div>

This plugin is being developed for desktop first site, so mobile accessibility isn’t a requirement that needs to be considered.

0
Mance Rah 3 weeks 2023-03-06T13:45:22-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse