Condition to Check if the Current Category Has At Least One Child

Looking to render an element in the category archive Bricks template only if the category of the current category archive page is a parent?

This Pro tutorial shows how.

Add the following in child theme‘s functions.php (w/o the opening PHP tag) or a code snippets plugin:

// Function to check if the current category archive page has at least one child category.
function bl_is_parent_category() {
	if ( is_category() ) {
		$cat = get_queried_object();

		if ( $cat->category_parent === 0 ) { // if the current category is a top-level category
			$children = get_categories( [
				'child_of' => $cat->term_id,
				'hide_empty' => false,
			] );

			if ( ! empty( $children ) ) {
				return true;
			}
		}
	}

	return false;
}

and apply a Dynamic data condition on your desired element like this:

{echo:bl_is_parent_category}