$sep = '»';
$parents = get_category_parents( $cat, TRUE, $sep );
$parents = explode( $sep, trim( $parents, $sep ) );
if( 1 === count( $parents ) ) {
/* No category parents. */
require_once ( get_template_directory() . '/category-parent.php' );
}
else {
/* One or more parent categories. */
require_once ( get_template_directory() . '/category-child.php' );
}
solved WordPress If Parent { } else if child { } [closed]