Adding HTML to posts with certain tags?

When I want to add a site-wide HTML code (before the closing tag) to each post and page in my site, I always go to my:

  • WordPress Panel > Customize > Theme Settings > Header/Footer Scripts > Footer Scripts

And paste the code there. Works perfectly fine.

But now I want to add this code only to my posts with certain tags. I tried this (tags are X Y and Z):

function wpb_hook_javascript_footer() {
  if (has_tag ('X' 'Y' 'Z')) { 
    ?>
          // My HTML Code goes here
    <?php
  }
}
add_action('wp_footer', 'wpb_hook_javascript_footer');

But I guess it doesn’t work (update keeps loading, never ends)?

Any words of wisdom?

Go to Source
Author: user190411