How can I display a hint only on subpages with a special URL?

The following code inserts a hint on all subpages of a domain if a certain string is present within the URL.

function add_code_to_body() {
   if (strpos($_SERVER['REQUEST_URI'], 'zeichenfolge-in-der-url') !== false){ ?>
   <div style="background-color:#000;color:#fff;font-size: 17px;padding: 8px;text-align: center;">Here comes the hint.</div>
   <?php }
add_action( 'wp_body_open', 'add_code_to_body' );
Without cookies
This website does not use cookies or tracking. More information can be found in the privacy policy.