I tried to set up a custom post type in Wordpress, and everything worked just fine.
Until displaying a single post from my custom post type.
First it didn't automatically use the single.php
(as it should), and then I tried to create a custom single-{custom_post_type}.php
but it doesn't even use that one :/
I'm kind of confused now.
//Edit:
Solved the problem. Just had to add flush_rewrite_rules();
after register post type in functions.php
register_post_type( 'communitydeals' , $args );
flush_rewrite_rules();
flush_rewrite_rules()
are expensive to run on every page loadflush_rewrite_rules()
in your theme, it is not in theme scope, You can write and small plugin and use this codeadd_action( 'after_switch_theme', 'flush_rewrite_rules' );
to flush rewrite rule for custom post type only when you change theme . Or only updating permalink structure once from Admin Menu >> Settings >> Permalinks will make it work fine there too.