woocommerce offtopic - Exclude Specific Product Category for showing up in its parent category page

I am displaying a list of product sub-categories in a grid format in the parent Categories. There is a specific category

I am displaying a list of product sub-categories in a grid format in the parent Categories. There is a specific category with id 7000 which I want to exclude from the grid.

How do I accomplish this? I have tried the methods mentioned at but they did not work for me so what is the best way to accomplish this?

Here is how my code for archive-product.php looks like

<ul class="products columns-4">
        <?php
        $p_childrens = get_term_children($queried_object->term_id, $queried_object->taxonomy);
        if (!empty($p_childrens)) {
            foreach ($p_childrens as $p_children) {
                $c_term = get_term($p_children, $queried_object->taxonomy);
                if (!empty($c_term)) {
                    $term_link = get_term_link($c_term);
                    $thumbnail_id = get_woocommerce_term_meta($c_term->term_id, 'thumbnail_id', true);
                    $image = wp_get_attachment_url($thumbnail_id);
                    if (empty($image)) {
                        $image = wc_placeholder_img_src();
                    }
                    ?>
                    <li class="product-category product">
                        <h3><?php echo $c_term->name; ?></h3>
                        <a href="<?php echo $term_link; ?>">
                            <img src="<?php echo $image; ?>" alt="<?php echo $c_term->name; ?>"/>
                        </a>
                        <a class="btn btn-primary" href="<?php echo $term_link; ?>">View All Products</a>
                    </li>
                    <?php
                }
            }
        }
        ?>
    </ul>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745237007a4617952.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信