• Hi,

    I would like to apply different themes, as downloaded from https://themes.wordpress.net/, to different categories.

    I want to do this because at the moment it is the simplest way I see I can set up a blog where all my family can post and exchange news while having their own customized areas of the blogs (the categories) and without having to deal with the administration of the blog.

    I read a lot of the codex, and it seems very possible to achieve this. Unfortunately, there is a lot I don’t quite understand, and most of all the following: in https://codex.www.ads-software.com/The_Loop_in_Action , down at “The Loop In Other Templates”, it is often said to simply copy index.php to archive.php or category.php and edit it. But when I open index.php, there is very little to edit:

    <?php
    /* Short and sweet */
    define(‘WP_USE_THEMES’, true);
    require(‘./wp-blog-header.php’);
    ?>

    I tried anyway to edit it to point to the header of the theme I want to use for this category as follows:

    <?php
    define(‘WP_USE_THEMES’, true);
    require(‘./wp-content/themes/theme_dir/header.php’);
    ?>

    I also tried the ‘post-templates-by-category’ plugin, but I didn’t get it to work yet either.

    Help, please? Any suggestions?

Viewing 12 replies - 1 through 12 (of 12 total)
  • it is often said to simply copy index.php to archive.php or category.php and edit it. But when I open index.php, there is very little to edit:

    You’re confusing index.php files. The one you want is located in /wp-content/themes/theme_dir/. You don’t need to include it; just activate that particular theme.

    Thread Starter frankydoody

    (@frankydoody)

    Err… I’m completely confused. I don’t want to activate that particular theme: if I do that, this theme will be applied to the whole blog.

    What I want is to apply this theme to a category only.

    And another theme to another category.

    And, of course, the whole blog has its own theme; the one I can activate through the WordPress admin.

    Is that possible?

    Thread Starter frankydoody

    (@frankydoody)

    I suppose what I need to do is to have a category-X.php file that points to /wp-content/themes/theme_dir/theme_index.php.

    I just don’t know what code should be in category-X.php so that it points to the theme to use.

    carmenmich – start your own thread please. Your issue is not related at all to the original posters.

    Thread Starter frankydoody

    (@frankydoody)

    Yes, I saw and read the codex carefully more than once.

    There are 3 things I’d like to point at from that article.

    First, it is marked as in need of editing. I’d love to help and do that, but I’m obviously not knowledgeable enough in that domain as I’m requesting help regarding the very topic.

    Second, the part that is of most interest for me (“The Custom Category Template”) barely has any explanation, just a full page of code in which noobs like me get lost. In addition, it seems strange to me that it relies on a plugin to work. If you want to remove the part of the code that concerns the plugin (which creates a random list of posts of a category, which I don’t care for) you’re on your own: there are no comments indicating where and what is happening in there. I suppose that the earlier cases looked at before we get to the custom category template file are supposed to make it obvious to all, but it doesn’t, not for me anyway.

    And lastly,

    This is not for the timid, and familiarity with PHP syntax and WordPress template tags is recommended.

    Of course. Should I dig my own grave or look for some help in the forums? I am not timid, but I am unfamiliar with both. I thought that’s why there were articles, a codex and support forums.

    Seriously, I know some people just don’t read the codex and the articles and get straight to the forums. I didn’t, and I need help. I think I want to do something that is the topic of at least one of those articles, but I can’t do it.

    I’m sorry I sound frustrated: I really am. I’ve been at this for a while now, and I can’t seem to get it. I’m very confused as I tried many things with too many files and code I don’t master. Code is poetry, sure, but I hardly get the language. The article does cover many cases, however I don’t feel like I relate to them.

    Use what you have learned and put the whole thing together so you can see it in action, one category.php that generates custom information for each category on your site.

    This is exactly what I want. However, I find more explanation in another article: Different Formats for Different Categories and Different CSS For Different Categories (The Loop in Action) I can use the examples to create a single category.php with a conditional test to figure out which category is being shown and apply the theme (template and CSS files) corresponding to that category. And here’s what I come up with:

    <?php if (in_category('2') ):
    // we're in David's category, so show David's theme ?>
    <-- I need to put the code to point to David's theme -->
    <link rel="stylesheet" href="<?php get_template_directory(); ?>/wp-content/themes/David's_theme_dir/style.css" type="text/css" media="screen" />
    <?php } elseif (in_category('3') ):
    // we're in Brian's category, so show Brian's theme ?>
    <-- I need to put the code to point to Brian's theme -->
    <link rel="stylesheet" href="<?php get_template_directory(); ?>/wp-content/themes/Brian's_theme_dir/style.css" type="text/css" media="screen" />
    <?php elseif (in_category('4') ):
    // we're in Frank's category, so show Frank's theme ?>
    <-- I need to put the code to point to Frank's theme -->
    <link rel="stylesheet" href="<?php get_template_directory(); ?>/wp-content/themes/Frank's_theme_dir/style.css" type="text/css" media="screen" />
    <?php } elseif (in_category('5') ):
    // we're in Alex's category, so show Alex's theme ?>
    <-- I need to put the code to point to Alex's theme -->
    <link rel="stylesheet" href="<?php get_template_directory(); ?>/wp-content/themes/Alex's_theme_dir/style.css" type="text/css" media="screen" />
    <?php endif; // end the if, default theme for other categories ?>

    It doesn’t work. I was pretty sure it wouldn’t because I haven’t yet pointed to the right header.php, or index.php of the category’s theme. I don’t even get a screwed default theme when I click on the categories… is it even reading the CSS files?

    Briefly: as WP works today – you cannot have different themes for categories.
    This guy https://www.ads-software.com/support/topic/82537?replies=13 claims he has a different theme for one of the categories… although never explained what he meant by that.

    You can have different category templates, with different header and/or different stylesheet, but AFAIK – not a complete theme.

    Here is quite a good thread about Cat Templates (has a link to the code!)
    https://www.ads-software.com/support/topic/30653?replies=16

    I want to do this because at the moment it is the simplest way I see I can set up a blog where all my family can post and exchange news while having their own customized areas of the blogs (the categories) and without having to deal with the administration of the blog.

    Actually it seems to me that WordPress MU would be a much simpler solution for your needs.

    Thread Starter frankydoody

    (@frankydoody)

    Ok, thanks.

    I guess I’m off to make a test installation of WordPress MU, then. I just don’t know if posts made on different blogs can be shown on another one (a ‘central’ one), just like posts from different categories all show up on the main ‘page’ of a WordPress blog.

    Thanks for the links, as if it doesn’t work with MU, I’ll simply go for different headers for categories.

    Thanks again.

    ehm, what about creating different folders (domain.com/user1) or subdomains (user1.domain.com) and install WordPress in any folder/subdomain with a shared db? anyone should have his admin, ecc…

    Wow very nice idea but as l see its a bit hard. what l would do, but l didnt try yet to try to call the codes by
    making another changing variable for each theme ( ld ont know how to do it and than calling them from each categories , omg, it became more complex than l could imagine. Hey man l m a very new php learner, how can l know them. l m just tring to learn how to mudify my theme in https://www.bigphp.net , but it seems l would try this variables…
    get_header(TEMPLATEPATH . ‘/navigation.php’);

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Applying a theme to a category’ is closed to new replies.