child_position() returns the list position currently holding the widget that was passed as the argument. The widget needs to be passed by reference, i.e. using the form $widget.