get_the_categories() but exclude children of “Uncategorized”

Check if $cat->category_parent != 1 (assuming uncategorized has the default ID of 1). If your subcategories are deeper than one level you’ll need to use get_ancestors to determine the top level category.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)