使用WooCommerce显示子类别标题

时间:2014-02-01 18:20:28

标签: wordpress woocommerce

我有关于子类别WooCommerce插件的问题。我希望按标题显示所有主要类别的子类别。请给我一个关于这个问题的建议。

1 个答案:

答案 0 :(得分:0)

我觉得应该有所帮助。

我将所有类别放在一个名为var的术语中,并根据$args中的数组使用query_posts,您可以根据子类别需要更改它。您可以使用'order_by'属性:http://codex.wordpress.org/Function_Reference/query_posts

<?php
    global $post;
    $terms = get_the_terms( $post->ID, 'product_cat');
    foreach ( $terms as $term )


    $args=array(
            'taxonomy'=>'product_cat',
            'term' => $term->slug,
            'orderby' => 'title', 'order' => 'ABS'
                  );

      query_posts( $args ); 
    ?>

    <?php if ( have_posts() ) : ?>

    <?php while ( have_posts() ) : the_post(); ?>
        <li> <a href="<?php the_permalink(); ?>" id="booklink"><?php the_title(); ?></a></li>
        <?php endwhile?>
相关问题