使标签在woocommerce中显示为下拉菜单 [英] Make tag show as dropdown in woocommerce

查看:20
本文介绍了使标签在woocommerce中显示为下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 wordpress 显示标签的代码:

我想让它显示为下拉菜单,但我无法弄清楚:(有人可以帮我吗

解决方案

</表单>

请您试试上面的代码好吗?

Hi this is the code to the wordpress shown tags:

<label><?php _e('Tags', PLSH_THEME_DOMAIN); ?>:</label>
                    <?php
                    foreach($tags as $tag)
                    {
                        echo '<a href="' . plsh_assamble_url($shop_page_url, array('product_tag=' . $tag->slug), array('product_tag')) . '"';
                        if(plsh_get($_GET, 'product_tag') == $tag->slug) echo 'class="active"';
                        echo '>' . $tag->name . '</a>';
                    }
                    ?>

I want to make this shown as drop-down menu but I can not figure it out :( can someone help me pls

解决方案

<label><?php _e('Tags'); ?></label>
<form action="<?php bloginfo('url'); ?>/" method="get">
    <div>
        <?php
        $args = array(
            'taxonomy' => 'product_tag', // Taxonomy to return. Valid values are 'category', 'post_tag' or any registered taxonomy.
            'show_option_none' => 'Select tag',
            'show_count' => 1,
            'orderby' => 'name',
            'value_field' => 'slug',
            'echo' => 0
        );
        $select = wp_dropdown_categories( $args );
        $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
        echo $select;
        ?>
        <noscript><div><input type="submit" value="View" /></div></noscript>
    </div>
</form>

Would you please try above code?

这篇关于使标签在woocommerce中显示为下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆