Ok, after poking around in the database, here is what I learned.
Pages’ templates are not stored in the _post table, they’re in the _postmeta table. When I changed my tables to have a prefix other than wp_ , all the pages I had assigned templates to lost them.
I changed my tables by backing up, then using a text editor to search and replace the wp_ prefix to mine, let’s call it new
, then dumping the old tables and importing the altered database. It turns out that the required metakey is _wp_page_template, and by my search and replace I turned it into an unrecognized key, as you can see in these before and after snapshots of the database :
After the update, before I fix the page :
Edit Delete 153 99 _edit_last 2
Edit Delete 152 99 _edit_lock 1277486519
Edit Delete 154 99 _new_page_template testpage.php
When I look in the WordPress interface for page 99, I see “default template” listed. Once I change it manually in the interface to the template it should be I get this :
Edit Delete 153 99 _edit_last 3
Edit Delete 152 99 _edit_lock 1277486663
Edit Delete 154 99 _new_page_template testpage.php
Edit Delete 238 99 _wp_page_template testpage.php
So, the solution is to either exclude the contents of the _metapost table when searching and replacing, or to patch it up afterward.
Now, however, I’m concerned that there might be other places in the database where I haven’t yet noticed something broken. I found lots of tutorials online stating that one should update the wp prefix either through search and replace, or manually, to secure a site.
Can anyone provide a link to a more robust approach, and/or to a list of places we should NOT update the wp_ prefix in the database?
Thanks!