So, I’m in the process of writing a plugin for a specific site.
I understand WordPress picks the page template from the theme, with php script names according to the chart below. However, I’d like to write a script for my plugin and have WordPress include my script when it searches for the page template.
I know this is typically the job of the theme. I also know child themes are used to override this behavior. Is this something plugins can do as well?

WordPress has a template_include
filter which you can use.
// Add a filter to 'template_include' hook
add_filter( 'template_include', 'wpse_force_template' );
function wpse_force_template( $template ) {
// If the current url is an archive of any kind
if( is_archive() ) {
// Set this to the template file inside your plugin folder
$template = WP_PLUGIN_DIR ."https://wordpress.stackexchange.com/". plugin_basename( dirname(__FILE__) ) .'/archive.php';
}
// Always return, even if we didn't change anything
return $template;
}
It would be wise to allow your users to decide which archives are affected. Many sites have custom post types and may not want those archives affected like other post types. You can add an options page that dynamically pulls all post types on the current site and allows them to toggle your plugin on or off for each. Once you have that, you’ll need to again dynamically pull all post types, and then dynamically build “if” statements for each one. For example, if(is_archive('event') && $eventtoggle == true
– if it’s an archive of this specific type and the user toggled the plugin on for this specific type.