2016-09-19 96 views
0

你好,这是代码WordPress的显示标签:我想使这个显示为下拉菜单,但我无法弄清楚:(可有人制作标签显示在下拉woocommerce

<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>'; 
        } 
        ?> 

帮我请

回答

2
<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> 

请你试试上面的代码?

+0

是这个工作,但它给了我的网页标签我想要得到的产品标签(woocommerce产品),你可以帮我弄woocommerce产品标签以同样的方式这些标签是? – Argjent

+1

请问您可以使用'product_tag'而不是'post_tag'来更改您的'taxonomy'名称吗? – purvik7373

+0

是的,我做到了这一点,它比你的工作:) – Argjent