Support » Themes and Templates » Trouble with different single.php pages

  • Hey gang! Hoping someone can help me out, as I’ve been bashing my head against this problem for a little while now.

    I am building a custom theme for this site:

    I want the single post pages to have different layouts, depending on if they are news items, videos, or pictures, so I have the ‘single.php’ file acting as a sort of filter. If it’s category A, use single-A.php, if category B, use single-B.php etc.

    I had this working great on the BETA site, but now that I’ve re-installed WP on the root domain, things are funky. It seems like it was due to the categories having different IDs on the new site, and once I updated all of the cat-ID references, everything seemed to work, but one category (pictures, aka ID 7) is way messed up:

    Let me know if there’s any other info I can provide you with – Any help I can get would be greatly appreciated!



Viewing 2 replies - 1 through 2 (of 2 total)
  • Chip Bennett


    Theme Review Admin

    You may be better off sorting by category slug, rather than by category ID, for just the reason you encountered.

    Of course, a better approach entirely might be to use a custom taxonomy (see, e.g. the Post Format taxonomy), that will give you the ability to add classes to body_class() and post_class(), as well as allow you to make use of conditionals such as has_tax().

    Yeah, I tried slug instead of ID, but that didn’t work for any of my category coding.

    It feels like it’s just something with the loop, where for some reason, it’s grabbing extra posts. Would it help to see my template code at all?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trouble with different single.php pages’ is closed to new replies.