So basically, I'm trying to check if the user wants to overwrite my plugin template in his theme.
I have a plugin with a Custom Post Type 'links'. According to WP template system my archive file is 'archive-links.php'.
So, why does my check for the file 'archive-links.php' in the template folder always return false?
if(is_post_type_archive('links')) {
$file = get_template_directory_uri() . '/archive-links.php';
if(file_exists($file)) {
// echo('working');
// template overwrite
return get_template_directory_uri() . '/archive-links.php';
} else {
// echo('not working');
// default plugin archive file
return plugin_dir_path(__DIR__) . 'templates/archive-links.php';
}
}
add_filter
call is missing as is the function name etc