小编Ind*_*ola的帖子

Wordpress 自定义帖子类型分类模板

我有一个名为“产品”的自定义帖子类型,它有一个分类“产品类别”,其中有类别 1、类别 2 等。它又具有子类别类别 1a、类别 2a 等。我想要的是,当我点击时类别 1,它应该列出子类别类别 1a、类别 2a 等。当点击类别 2a 时,它应该列出与类别相关的产品。我怎样才能用wordpress实现这一点?

<?php $taxonomy_name = 'al_product_cat'; 
$term_childs = get_term_children( $wp_query->get_queried_object_id(), $taxonomy_name ); //print_r($term_childs);
foreach($term_childs as $child){ 
    $tm = get_term_by( 'id', $child, $taxonomy_name ); ?>
    <div class="tax_content">
        <div class="feat_thumb"></div>
        <div class="feat_content">
            <h2><a href="<?php echo get_term_link( $child, $taxonomy_name ); ?>"><?php echo $tm->name; ?></a></h2> 
            <p><?php echo $tm->description; ?> </p>
            <div class="brand_logos">
            <?php $terms = get_the_terms( $wp_query->get_queried_object_id(), 'brand' ); 
            foreach($terms as $term){
            ?>
                <img src="<?php echo z_taxonomy_image_url($term->term_id); ?>" />
           <?php } ?>
        </div> …
Run Code Online (Sandbox Code Playgroud)

wordpress wordpress-theming

5
推荐指数
1
解决办法
7191
查看次数

标签 统计

wordpress ×1

wordpress-theming ×1