Trouble with different single.php pages (3 posts)

  1. jacobreed
    Posted 4 years ago #

    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!



  2. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    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().

  3. jacobreed
    Posted 4 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic