Hi Corine,
Thank you for sharing these details and your observation is correct.
Whenever a view is created with a content template, an association is created between that view and the content template, in the database.
And when a duplicate of that view is created, another content template with that duplicated view is created with a similar association.
And as long as a content template is part of an association with a view, the option to delete it is not available in the list of content templates.
Since you don't need to maintain these associations between the views and the content templates, you can follow these steps:
1. Make a complete backup copy of the website.
2. Add the following code to the active theme's 'functions.php' file:
add_shortcode( 'custom_shortcode_SQL', 'custom_shortcode_SQL_func');
function custom_shortcode_SQL_func()
{
global $wpdb;
$sql = "DELETE FROM `wp_postmeta` WHERE meta_key='_view_loop_id'";
$results = $wpdb->get_results($sql);
$sql = "DELETE FROM `wp_postmeta` WHERE meta_key='_view_loop_template'";
$results = $wpdb->get_results($sql);
}
3. Create a temporary page and include this new shortcode in the page's content:
Visit the page's front end, so that the code can be executed in the back end.
4. Check the content templates list and they'll be deletable, as the associations should have been deleted.
5. Once confirmed, you can delete the temporary page as well as remove the code from the "functions.php" file.
I hope this helps and please let me know if you need any further assistance with this.
regards,
Waqar