WP Bakery woocommerce显示产品子类别(FREE)

问题描述 投票:0回答:1

Internet上的可查询的交易消息,互联网上的民意调查表。

问题问题时代,客户分类的主要中间货币和简码。微型亚细亚独奏曲,产品总冠军奖杯。


你好朋友。

我想与您分享这项工作,因为我没有在互联网上找到任何解决方案,所以我不得不建立自己的解决方案。

问题是客户希望使用简码显示主类别中的子类别。仅子类别的名称,不包括缩略图或产品数量。

wordpress woocommerce categories visual-composer wpbakery
1个回答
0
投票

[Asique cree un archivo llamado“ products-subcategory.php” zh-插件/ bezel-addons / vc / shortcodes /。合并插件/bezel-addons/vc/shortcodes.phpEnBészelen en caso mi plantilla es la Bezzelhttps://themeforest.net/item/bezel-creative-multipurpose-wordpress-theme/20014332使用Visual Composer或WP Bakery可以实现通用的语言。


因此,在plugins / bezel-addons / vc / shortcodes /中创建一个名为“ products-subcategory.php”的文件。我将其合并到plugins / bezel-addons / vc / shortcodes.php中在我的情况下,我的模板是Bezzelhttps://themeforest.net/item/bezel-creative-multipurpose-wordpress-theme/20014332但是我认为您可以使用Visual Composer或WP Bakery在任何人中实现它。


products-subcategory.php。

<?php
/* Product subcategory  */
vc_map(
  array(
    'name' => 'Subcategorias de Producto',
    'base' => 'bezel_products_subcategory',
    'icon' => 'ti-align-left',
    'description' => 'Subcategorias de producto',
    'category' => __( 'Bezel', 'bezel-addons'),
    'params' => array(
      array(
        'type' => 'dropdown',
        'param_name' => 'orderby',
        'heading' => 'Ordenar por',
        'value' => array(
          'Nombre' => 'name',
          'ID' => 'term_id'
        ),
      ),
    array(
        'type' => 'dropdown',
        'param_name' => 'order',
        'heading' => 'Sentido del orden',
        'value' => array(
            'Ascendente' => 'ASC',
            'Descendente' => 'DESC'
        ),
      ),
        array(
        'type' => 'dropdown',
        'param_name' => 'empty',
        'heading' => 'Mostrar categorias vacias',
        'value' => array(
            'SI' => 0,
            'NO' => 1
        ),
      )

    )
  )
);

add_shortcode( 'bezel_products_subcategory', 'bezel_products_subcategory' );

function bezel_products_subcategory( $atts ) {
 global $wp_query;

    extract( shortcode_atts( array(
        'taxonomy' => 'product_cat',
        'orderby' => 'name',
        'order' => 'ASC',
        'empty' => 0,
        'hierarchical' => 1
  ), $atts ) );

    $cat = get_queried_object();        
    $category_id = ($cat->parent) ? $cat->parent : $cat->term_id;
    $args2 = array('taxonomy' => $taxonomy,'parent' => $category_id,'hierarchical' => $hierarchical, 'orderby' => $orderby, 'order' => $order,'hide_empty' => $empty);
    $categories = get_categories( $args2 );
    $categories_cnt = count(get_categories( $args2 ));

    $selcat[$cat->term_id] = 'current-cat';

    if ($categories_cnt != 0){

        $sub_cats = get_categories( $args2 );
        if($sub_cats) {
            $output = '<div class="vc_wp_categories wpb_content_element">';
            $output .= '<div class="widget widget_categories">';
            $output .= '<ul>';
            foreach($sub_cats as $sub_category) {
                $output .= '<li class="cat-item cat-item-'.$sub_category->term_id.' '.$selcat[$sub_category->term_id].'"><a href="'.get_category_link($sub_category->term_id).'">'.$sub_category->cat_name.'</a></li>';
            }
            $output .= '</ul>';
            $output .= '</div>';
            $output .= '</div>';
        }
    }

  return $output;
}
?>

Espero que le sirva a alguien。

我希望这对某人有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.