I have the exact same problem. I was really scratching my head on this one until i realised this plugin was causing it.
Sorry i dont have seen your related topic.
It took me a lot of time to find this issue.
Did you solve it in the end? It’s a pity the plugin doesn’t seem maintained any longer with updates…
Yes, I deleted the plugin 😉
😉
For some projects i’d need a plugin to switch post types, but i didn’t find any alternative. In case you know, please let me know.
It seems that override_type()
method is rewriting the attachments that are set in the ACF field to pages.
The media files aren’t really deleted but have their post type changed to ‘page’ in the database. Which renders them invisible in the media screen. The files are in the db and in the uploads folder.
So you can basically run a simple query to find all the ‘missing’ media files with
global $wpdb;
$wpdb->query( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = %s AND guid LIKE %s", 'page', '%uploads%' ) ); // This can be output to print_r or error_log
To change the missing files to ‘attachment’ You should run
global $wpdb;
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_type = %s WHERE post_type = %s AND guid LIKE %s", 'attachment', 'page', '%uploads%' ) );
I did mine in phpMyAdmin with direct queries, but these should work from within the WordPress (put them in functions.php
in after_setup_theme
hook for instance). Also once you do this, remove the queries, because they are no longer needed.
Great, thanks for the instructions how to fix it, dingo-d !
Did anyone find a solution to this? I deleted the Post Type Switcher plugin but images are still disappearing whenever I update a page
Bug is fixed in versions 3.1.0 and higher.
Plugins shouldn’t be calling update_post()
inside existing calls to update_post()
but, they do, so I’ve updated PTS to look for that recursive condition and avoid this problem.