WordPress.org

Ready to get started?Download WordPress

Forums

How to make single posts follow category templates? (8 posts)

  1. Luxt
    Member
    Posted 8 years ago #

    Hi... new one here :!

    [brief introduction] A few months ago, a couple of friends and I had the idea to start a website [blog styled] where we could post anything related to the things we love...

    We thought of how to arrange the site's content, what it was going to have, etc... Using PS I made the design, which right now is about to change... I did some websites on the past using MT, but with this one, MT wasn't going to work, simply because I wanted a dynamic site, "easy" to build, intuitive and very flexible. I spent weeks searching for the perfect script, and I finally got into WordPress which I knew would fulfill my needs. [/brief introduction]

    So far, in just a few days I managed to learn some CSS basic knowledge and an incredibly basic knowledge on WP [by basic, I mean I managed to rearrange the php tags to make the website's layout]

    Right now, I managed to finish the home page and began to work on the category pages.

    [You can see an example here: http://img276.echo.cx/img276/8281/genshwp1ec.jpg

    However, I knew that single posts were going to be a pain...

    I did some research in codex and the support forums.
    I found some topics that were really interesting, but unfortunately, not very helpful... however, they did give me an idea of what I wanted. For instance, The Loop @Codex wasn't very begginer-friendly so I find myself posting this.

    Since my website will have 12 main categories or so, with at least 60 subcategories, the style of each post is very important in order to have an stylish [?] site.

    Basically, there will be 12 main categories, each one will have a different layout, and there will be about 60 subcategories that will follow the theme of those 12 main categories.

    What I want to do right now, is have every single post page follow its parent category template... unfortunately, making hundreds of single-x.php is not an option.

    ... so, how can I do it? *sigh*
    Unfortunately, I know pretty much nothing of PHP... I thought of using conditionals [maybe category conditional tags, http://codex.wordpress.org/Conditional_Tags which might be exactly what I need but I wasn't able to use them properly [actually, I didn't even know where to begin :S].

    So... any generous soul willing to help me?

    Thanks in advance, and sorry for my not-so-good English.

  2. Lorelle
    Member
    Posted 8 years ago #

  3. Firas
    Member
    Posted 8 years ago #

    The only way I can think of is to make the single.php a huge switch statement that checks the current category and, well, has the parts of the category template you want in there.

    Then again, 12 switch statements isn't too bad ;)

  4. error
    Member
    Posted 8 years ago #

    At that point you may as well take single.php, copy it, and customize each copy.

  5. Lorelle
    Member
    Posted 8 years ago #

  6. Luxt
    Member
    Posted 8 years ago #

    Wow, thanks for the quick response.

    Right now, I'm at work so, unfortunately, I'll be able to check Lorelle's info when I get home.
    I read what was posted on your site and I think that might do the trick... So, by doing that, I will only have to make 12 single-x.php, put in the conditionals and the includes according to the post's category...

    12 files against n files... quite interesting :p

  7. Lorelle
    Member
    Posted 8 years ago #

    Remember, the method that I have on my site is good for a few categories. If you want 46 categories to be different, there is an easier way to do that. ;-)

  8. Kafkaesqui

    Posted 8 years ago #

    There is a plugin solution I cobbled together for this, which lets you assign category templates to single posts:

    http://wordpress.org/support/topic.php?id=27821#post-156289

Topic Closed

This topic has been closed to new replies.

About this Topic