As you only want a select form field that has a categories children, then simply go with wp_list_categories()
wp_list_categories( array(
'child_of' => 'your parent cat ID',
) );
Depending on your use case, you could as well use
-
get_the_category()and itsget_the_categoriesfilterapply_filters( 'get_the_categories', $categories ); -
get_the_terms()and its filter (the function is called internally byget_the_category():apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy ); -
get_categories(), pass a special key to the arguments input array (e.g.my-special-list) that you then check in a callback on the filter inside the function and alter the output there. The function callsget_terms()after the filters callbacks get called.apply_filters( 'get_categories_taxonomy', $taxonomy, $args ); get_term_children( $term_ID, 'category' )
Edit The main queried object can always be retrieved using get_queried_object(). And there’s a function to extract its ID: get_queried_object_id().