• Resolved Jeff

    (@jmf)


    I’ve got several post types defined in a custom theme, one of which is ‘Book Review’. According to the codex, I should be able to make a template page called ‘single-book_review.php’ which will display single posts of the type ‘Book Review’ correct? If so, for some reason, it’s not working for me. Instead, the post displays with the single.php template.

    Just so I’m certain there are no coding glitches, I’m using the same code in both single.php and single-book_review.php template pages. On the single.php page, I’ve included an <? echo get_post_type(); ?> snippet. When I load a Book Review post, it definitely pulls the single.php page, and displays book-review in place of the snippet.

    I’m not sure what rock I should turn over next…anything else I can do to troubleshoot this?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • is your post type registered as book_review? For instance:

    register_post_type( 've_products', array(
    		'labels' => array(
    			'name' => __( 'Products' ),
    			'singular_name' => __( 'Product' ),

    is how I register my custom post type. It’s displayed name is Products, but it’s actually named ve_products

    So single-ve_products.php works for me

    Thread Starter Jeff

    (@jmf)

    Aw, geez. I got it. I assumed from the example that the filename should include an underscore, even though my post type’s registered names used a hyphen. Changing to single-book-review.php seems to have done the trick. (Although I’d swear it didn’t work the first time I tried it, which led me to switch to underscores in the first place…)

    Anyway, thanks for the kick in the right direction, Rev. Voodoo!

    Glad it worked out for you!

    JsonB123

    (@jsonb123)

    I just wanted to hop in here cause I thought that I was experiencing the same issue. It was the same problem, but I was only getting the index page and not the single-post_type.php or archive-post_type.php page that I created.

    This is because you MUST go to Settings > Permalinks and save it again in order to toggle an update to your .htaccess settings in order for your new post-type rewrite settings to take effect. I had forgotten to do this and once I did everything worked perfectly.

    I forget to do this a lot…I need to drill this into my head somehow; luckily this time it took it only took me 15 minutes to remember :-).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘single-post_type.php Not Working For Me…’ is closed to new replies.