front end - How to select tags in the frontend

admin2025-06-05  8

Please help. I want users to be able to add posts from the frontend. It works for me, but I do not know how to do it to choose one of the existing tags. I have this code (used from here, but adjustable for my needs):

<?php
$taxonomies = array (
    'post_tag'
);
$args = array (
    'orderby' => 'name',
    'order' => 'ASC',
    'hide_empty' => false
);

$terms = get_terms($taxonomies, $args);

if(count($terms)> 0):

    foreach ($terms as $term):?>
        <div class="wissen_tag_list">
            <input type="radio" value="<?php echo $term->term_id; ?>" name="post_tag" class="post_tag_list" <?php if? php}?>>
            <label class="post_tag_list">
                <?php echo $term->name; ?>
            </label>
        </div>
<?php
    $i++; endforeach;
endif; ?>

My tags will appear, but there is no one to choose. Only the first one is selected. Can you please help me where I am wrong. These are standard tags, no custom.

Thank you very much.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749086886a316250.html

最新回复(0)