• Resolved meshdesign

    (@meshdesign)


    Hi all, i’ve been spending the last few weeks exploring custom post types in wordpress 3.0 and am slowly mastering it!

    One thing i can’t figure out though is how to associate a custom post type with a different template to single.php, i am building a gallery/portfolio and have built a portfolio-single.php page.. how do i connect the two?

Viewing 8 replies - 1 through 8 (of 8 total)
  • It’s all covered on the template hierarchy page, see here.
    https://codex.www.ads-software.com/Template_Hierarchy#Single_Post_display

    What you essentially need is a single.php but appended with your custom post type name (then it will all happen automagically), eg. single-books.php (if your post type was books).

    Thread Starter meshdesign

    (@meshdesign)

    love the use of the word automagically, not sure if it was a typo but it works!

    i’ll give it a whirl and let you know how i get on with it!

    Sure thing, i’ll be here if you need help.. ??

    Hi Guys,

    I’m trying to do this also but have a couple of questions:

    do i need a single.php file in my theme if i have a single-default.php, single-cptA.php and single-cptB.php set of files?

    should i rename the single-default.php to just single.php?

    thanks

    single.php should be present, it is the standard file WP will look for, so you can rename single-default to single.php, or if it is somehow used for something, make a copy of it and name it single.php

    single-whatev.php is used by the custom post type preferentially, if one is not present for that cpt, then single.php would be used

    single.php is also needed for standard non cpt type posts, or else index.php is used

    thanks for the reply, the reason i ask is that i’ve got a single.php file with routes my two custom post types by category. I’ve been trying to get them to route correctly and wondered if the single-whatever.php would ‘over-rule’ the routing by category in my single.php file.

    any ideas?
    thanks

    if you have single-whatever.php set up for your cpts, it would overrule the routing in single.php, as single.php would never load….. the single-whatever.php would auto load.

    to route by category, you can use category-whatever.php as well…..

    Rev. Voodoo, thanks for your replies but it seems i’m still a little stuck. I’m beginning to think that ,y issue goes a little deeper.

    Would it be possible for your input on the following thread:
    link

    i’ve seriously been searching around and testing based on the wealth of information here but i’m really in need of some experience with my problem. thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom Post Types to Custom single.php’ is closed to new replies.