• I’m creating a template in DIVI: I need to return just the sub-categories of the present category.

    As this will be used for many different parent categories, I can’t use the usual shortcode [category=”category-name”]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Please check the below code. For that in url pass the parent-category name like
    https://yourdomain.com/product-category/categoryname

    Where category name is your current parent-category

    $terms = get_terms([
        'taxonomy' => get_queried_object()->taxonomy,
        'parent'   => get_queried_object_id(),
    ]);
    foreach ( $terms as $term) {
        echo '<p class="filters"><a href="' . get_term_link( $term ) . '">' . $term->name . '</a></p>';
    }

    Please check and let me know.

    Thanks

    Thread Starter Phil Emery

    (@noise)

    Doesn’t seem to work for WooCommerce.

    Hi @noise,

    I tested this with the Storefront theme and it did seem to work. Divi has several template overrides itself, as well as different plugins that help facilitate the theme’s functionality. Due to this, it is possible that code needs to be tweaked to be able to work with Divi. In that case, it is best to reach out to the theme developers directly of Divi and see what they can do to assist in setting the template.

    I am going to close this thread. If you still have the issue feel free to reply back and let us know, and the thread will re-open. If there is a new issue, please open a new thread.

    Otherwise do have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to: Dynamic Display of Subcategories of Current Category?’ is closed to new replies.