Thursday, November 19, 2015
Tuesday, September 7, 2010
Select Custom Post Template Based on Category
I rely on custom post templates on one of my sites. Recently I ran into an issue when I upgraded to WordPress 3.01. I used the plugin Category Templates to assign my posts a specific custom post template. After the upgrade to 3.01 The Category Templates plugin partially broke. I could still go into an individual post and select which Custom Post Template to use but all of my posts lost the initial custom post template they were assigned to. The Custom Post Template plugin also has a bulk assignment utility but that didn’t work after the upgrade. I was stumped for a couple of days on how to easily resolve the problem. Manually going into 13,000 posts wasn’t an option!
In my research I stumbled across a posting on the WordPress forums. Ronald73 posted a coding solution that accomplished exactly what I needed. Here is his solution: