WordPress Custom Post Type Single Template Not Working

November 13th, 2013 - Posted by Steve Marks to PHP, Web Development.

I can’t think of the last WordPress site I did that didn’t use custom post types. They’re a feature I use all the time. As a result of using these custom post types, they often require a different layout to each other, and to the standard posts.

To do this you can use the built-in WordPress template heirarchy and name your template files in the format ‘single-customposttype.php’. Then, when viewing these custom post types, it should default to this template.

The Problem

A common problem I used to come across, and that I still see mentioned a lot today, is that when doing this it’s not using the single template that has been setup up for the post types. Instead it will default to the standard single.php.

The Solution

From what I can tell, this scenario arises particularly when the custom post type has been added after the permalink settings were last updated. What’s happening in the background, I’m not sure, but fortunately the solution is simple.

To get the custom post type’s single template working, you simple need to re-save the permalink settings in WordPress. Simply navigate to ‘Settings > Permalinks’ and click save.

Tags: ,
This entry was posted on Wednesday, November 13th, 2013 at 11:26 am by +Steve Marks and is filed under PHP, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (0)

No comments have been left yet. Be the first