Loading a template for a URL pattern

To determine the best filter to use, you have to determine what those pages are. Is is_page() true? Use the page_template filter. Is is_post_type_archive() true? Use the archive_template filter.

All of the query type-specific template filters are listed here.

You can also use the generic template_include, which fires for all types.

Within any of these filters you can check the same conditions you need to determine if you need to load the template-gallery.php template.