最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

front end - How to select tags in the frontend

matteradmin10PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far