Retrieve Existing Taxonomy Values For Form As Checkbox
-
Hello all. Thanks for taking a look at my question.
What I have…
A front end submission form that allows members to submit posts for a custom post type: ‘game-previews’. I have several custom_meta and custom taxonomies on the form. All is fine, except one instance.
Where I’m stuck…
I have one custom taxonomy where I don’t want members to just randomly type new terms (or guess existing ones..lol). The submitter will also need to be able to select multiple taxonomies if they choose. This taxonomy is called ‘game_platforms’. I know how to display the existing taxonomy values in a drop-down by using…
<fieldset> <div class="platform-type-input"> <h3>What Type of Platform Is It?</h3> <?php $platformtypes = get_terms('game_platforms', 'hide_empty=0'); ?> <select name='game_platforms' id='game_platforms' style="width: 95%" class="required"> <!-- Display taxonomies as options --> <?php $names = wp_get_object_terms($post->ID, 'game_platforms'); ?><option class='game_platforms' value='' <?php if (!count($names)) echo "selected";?>>Please Choose A Platform Type</option> <?php foreach ($platformtypes as $game_platforms) { if (!is_wp_error($names) && !empty($names) && !strcmp($game_platforms->slug, $names[0]->slug)) echo "<option class='game_platforms' value='" . $game_platforms->slug . "' selected>" . $game_platforms->name . "</option>\n"; else echo "<option class='game_platforms' value='" . $game_platforms->slug . "'>" . $game_platforms->name . "</option>\n"; } ?> </select> </div> </fieldset>
This I’ve used in another instance for another situation on the project, but in this case, I can’t seem to figure out how to fetch & display the existing taxonomy values in a checkbox format for the form.
Any thoughts, guidance, tips, snippets would be greatly appreciated. Thanks in advance.
- The topic ‘Retrieve Existing Taxonomy Values For Form As Checkbox’ is closed to new replies.