N
N
Nixin7772017-07-13 12:15:30
WordPress
Nixin777, 2017-07-13 12:15:30

How to check that you are on the subcategories page?

In the archive-product.php file, you need to write a condition that if you are on a subcategory page, display a message. It is important that only on subcategories and not on categories

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksym Davydchuk, 2017-07-13
@Nixin777

Try this solution:

<?php 
function is_subcategory ($catid) {
    $cat_data = get_category($catid);
    if ( $cat_data->parent )
        return true;
    else
        return false;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question