Status
Not open for further replies.

r00ts

Banned
Banned
147
2011
13
0
Ok, i would like to have, differen CSS for post titles for each different category.
For example.
All posts from category a coloured red
All posts from category b coloured green

Here are some codes i have tryed and people are sayign that they are working but why dont they work for me?
My post titles defautl colour is fetched from post.css and not basic.css

The codes i tryed:

Code:
[LIST=1]
[*]get the cat id nr. like "194" for w33d on www.something.kom
[*]<h2 id="color_<?php  foreach((get_the_category()) as $category) { echo $category->cat_ID .  '';} ?>">blaaaaaaaaaablaaaaaaaaaaaaablaaaaaaaaaaaa</h2>
[*] 
[*]CSS file like
[*]#color_194 a {
[*]        color:#99FF00;
[*]}
[/LIST]

This one

Code:
open file -> index.php

past code under
<div class="post-header">
------------------------------------------------------------------------------
<h2 id="color_<?php foreach((get_the_category()) as $category) {
    echo $category->cat_ID . '';
} ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>

------------------------------------------------------------------------------

go to your theme folder => stylesheets folder
open file -> basic.css
XXXXXXXXXXXX = your cat ID
------------------------------------------------------------------------------
.post-header #color_XXXXXXXXXXXX a {
    color:#FFFF00;
    text-decoration: none;
    font-family: Verdana;
    font-size: 11px;
}
.post-header #color_XXXXXXXXXXXX a:hover {
    text-decoration: underline;
    border: none;
    color:#FFFF00;
}
.post-header #color_XXXXXXXXXXXX a:visited {
    border-bottom: 1px dotted;
    text-decoration: none;
}

And this one

Code:
[LIST=1]
[*]Post that code in your <head>......</head>
[*] 
[*]Different CSS For Categories
[*] 
[*]For having different CSS for the categories use the following code :-
[*] 
[*]     
[*]    <?php if( is_category( 1 ) ) { ?>
[*]    <link rel=â€stylesheet†href=â€URL of style1.css†type=â€text/css†media=â€screen†/>
[*]    <?php } elseif ( is_category (2) ) { ?>
[*]    <link rel=â€stylesheet†href=â€URL of style2.css†type=â€text/css†media=â€screen†/>
[*]    <?php } elseif ( is_category (3) ) { ?>
[*]    <link rel=â€stylesheet†href=â€URL of style2.css†type=â€text/css†media=â€screen†/>
[*]    <?php } else {  ?>
[*]    <link rel=â€stylesheet†href=â€URL of style.css†type=â€text/css†media=â€screen,projection†/>
[*]    <?php  }  ?>
[*] 
[*]Here 1,2&3 represents Category ID’s and style1.css, style2.css & style3.css represents their different CSS repectively.
[*] 
[*]http://www.dailytechpost.com/index.php/different-css-styles-for-different-pages-and-categories-in-wordpress/
[/LIST]
 
1 comment
Try any of them, right click on the element > inspect element. See from what file that element is being styled to. You can PM me the site so I can help you.
 
Status
Not open for further replies.
Back
Top