It would help to know what exactly you want to display on your category page.
Also, if you need a different style for each category, see this:
http://codex.wordpress.org/Category_Templates
Basically, I want it to appear just as the archive pages currently do. Which was typical of a category page I saw in another theme. This is what I have now, and I wish to keep: http://www.jbergdesign.com/archives/category/family/
But… I want to create a ‘category.php’ page so I can apply different styles to each category. Thanks for the Codex info, I read through that earlier. But, I need to be able to first create a category.php page in order to use that.
So… what I’ll need to know is ‘how do I CALL the category information’?
Also… has anyone actually been successful with that codex info? If so, I’d love to see your site and how each of your categories differ.
Have a look at this theme, it changes the header image dependant on the category selected.
http://www.curtisfamily.org.uk/?p=99
Maybe you can get an idea of how it is coded by downloading and disecting it.
Cool. Thanks, Marc. I’ll take a look! (Though, I may be back for more questions later! π
Well… looking at the files from Chris’s site, the category header ‘call’ is built into the header.php file. So… working with that, I managed to get it to call main header… but, it leaves a blank space where the header should be in the category pages.
So, obviously, I’m missing something. Hmm…
Considering this code to ‘call’ the category numbers:
<?php
if (is_category()) {
$imgurl = “images/”.single_cat_title(”,FALSE).”.jpg”;
} else {
$imgurl = “images/all.jpg”;
}
?>
and THIS line that calls the style sheet:
<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />
Does anyone know how I can change that to call a completely different style sheet (instead of just calling the image)?
I’m still having a difficult time with this ‘category’ subject. Can anyone help me with this?
I’ve managed to create a new ‘category.php’ file. I would like to give each category a different header and color palette. So, a different style sheet is necessary. I tried just using Curtis’s idea above to simply change the header – the images don’t show up: http://www.jbergdesign.com/archives/category/home-remodeling/
I’ve also tried reading through the codex/Category_Templates file – I don’t know php enough, yet, to figure out how to WRITE it, and I don’t think the ‘sticky-snip’ explanation is what I need.
Using the ‘Kubrick/default’ template to build my site, the call for the style sheet is in the ‘header.php’ file. So… how can I call separate stylesheets, that are each based on a different category, from that file?
I’m getting desperate here. So far, I’ve seen a lot o f people say this can be done and it’s easy, but I’ve only seen Curtis’ site as coming close to it.
As the Codex says: the category.php
template will apply to ALL your categories (instead of the archive.php or index.php – see hierarchy.)
The Codex also says you can create different templates for different categories, so you can have catgeory-1.php
for your category with ID# 1, category-2.php
for your category with ID# 2…etc.
Furthermore the good souls here on the forum hopefully can give you a hand to write the statements in the head(er) – if you are as unfamilliar with PHP as I am – to call for a different stylesheet.
However I think there is another way, too – though quite redundant and involves more work. Namely you can call into the catgeory-2.php
, for example, another header, let’s say header-2.php
in which you define what stylesheet will apply to the template.
I know it’s not an “elegant” solution but might work for PHP dummies π
I’ll take any solution I can find right now. π
I’ve been thinking about exactly what you said – creating different headers and categories. What’s stopping me from doing that right now is: I don’t know how to call a different stylesheet. This is all I’ve seen, so far: @import url( <?php bloginfo(‘stylesheet_url’); ?> );
So… I’m hoping someone can help me figure that code out.
I’m still VERY unfamiliar with PHP. I can pick my way through parts of it and say ‘Oh… that’s what that does.’ But, that’s it, for now. I did get a book, though. π
I’ve tried this on my local install and it worked π
Changed
@import url( <?php bloginfo('stylesheet_url'); ?> );
to this:
@import url( <?php bloginfo('url'); ?>/wp-content/themes/mytheme/newstyle2.css );
where “mytheme” is the name of the theme used/modified.
Cool! Okay… THIS worked! http://www.jbergdesign.com/archives/category/home-remodeling/
compared to: http://www.jbergdesign.com
This WILL give me a LOT of files. But, at least it’s a ‘temporary fix’ until I can figure out a more simplistic way to get it to work. I want this site up to have with my online resume (for design purposes). So, I’ve been busting a gut trying to get my different categories back online.
Thanks Moshu! I will be forever grateful for your help!!!! (well, until someone comes along with an easier route. Then, I’ll make sure I pass it along to you, too ;o)
Much thanks!!!!!!
Hopefully a PHP guru will come along and tell us how to use correctly the
<?php
if (is_category(2)) {
use XX stylesheet
if (is_category(6)) {
use YY stylesheet
} else {
use another stylsheet
}
?>
or something along those lines… I know the principle, just lacking the skills to write the code π
Same here. I know what I *want* to do… I jsut don’t know how to do it. If you ever find anything like that out, please pass it along. I’ll do the same. π
Afternoon everyone! Okay… this whole ‘category/style’ thing has been a bugger for a while for me. I think I’ve finally gotten it to work, with just one minor flaw:
please go here: http://www.jbergdesign.com
(remodeling, taekwon do, family, etc. – some have different styles, some keep the default)
It’s working, as it’s picking up the style sheets that for the different catagories. BUT, as you can see, I’m missing the header images. Can anyone see why that may happen?
This is from the css files (same in each, but, with different .jpg)
#header {
background: url(“images/category1.jpg”);
height: 120px;
margin: 0 auto;
width: 100%;
padding:0;
border: 1px solid #BEBEBE; }
Any thoughts as to why the background image refuses to show up? I’ll continue looking on my end. But, any thoughts would be appreciated! π
Got it working! Without having to create multiple category and header pages. I built the PHP into the header (which, in Kubrick, that’s where the call to the style sheets is). Then just created multiple style sheets for it to call. Here’s what I placed in the header.php:
<style type=”text/css” media=”screen”>
/* Calls the style sheets for each category */
<?php
$post = $wp_query->post;
if ( in_category(‘3’) ) {
include(TEMPLATEPATH . ‘/category3.css’);
} elseif ( in_category(‘4’) ) {
include(TEMPLATEPATH . ‘/category4.css’);
} elseif ( in_category(‘5’) ) {
include(TEMPLATEPATH . ‘/category5.css’);
} elseif ( in_category(‘8’) ) {
include(TEMPLATEPATH . ‘/category8.css’);
} elseif ( in_category(’13’) ) {
include(TEMPLATEPATH . ‘/category13.css’);
} elseif ( in_category(’15’) ) {
include(TEMPLATEPATH . ‘/category15.css’);
} else {
include(TEMPLATEPATH . ‘/style.css’);
}
?>
</style>
<?php /* Calls the header image for each category – necessary code */
$post = $wp_query->post;
if ( in_category(‘3’) ) {
$imgurl = “images/category3.jpg”;
} elseif ( in_category(‘4’) ) {
$imgurl = “images/category4.jpg”;
} elseif ( in_category(‘5’) ) {
$imgurl = “images/category5.jpg”;
} elseif ( in_category(‘8’) ) {
$imgurl = “images/category8.jpg”;
} elseif ( in_category(’13’) ) {
$imgurl = “images/category13.jpg”;
} elseif ( in_category(’15’) ) {
$imgurl = “images/category15.jpg”;
} else {
$imgurl = “images/all.jpg”;
}
?>
<style type=”text/css” media=”screen”>
/* Disable the header style in the individual style sheets and embed it here. */
#header {
background: url(<?php bloginfo(‘stylesheet_directory’) ?>/<?php echo $imgurl; ?>);
height: 120px;
margin: 0 auto;
width: 100%;
padding:0;
border: 1px solid #BEBEBE; }
</style>
The php code for the header images was partially what I put together from how the curtisfamily site runs. But, the rest was pieced together from the codex info and other bits and pieces I heard of from others.
It does exactly what I’ve been looking for. Took me 2 months, but hey! ;o)
Thanks for the help, Moshu.
Ok I’m a little loss here. I’ve got some idea but where do I put the code in the header? Am I make css sheet for all the category. I’m using Neptune how do I get it work with that. Thanks for the help greatly appreciate.