2016-09-19 93 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