Results 1 to 2 of 2
-
1st May 2012, 11:08 AM #1OPMember
Different css for different category.
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:- 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;
- }
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; }
Code:- 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/
r00ts Reviewed by r00ts on . Different css for different category. 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: Rating: 5
-
1st May 2012, 11:11 AM #2MemberWebsite's:
imdber.org justpaste.meTry 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.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Different CSS per category.
By pi0tr3k in forum phpBBReplies: 10Last Post: 18th Jan 2012, 05:06 PM -
No category base in url
By t3od0r in forum WordpressReplies: 8Last Post: 13th Jun 2011, 01:27 PM -
Category headings.
By neilbla in forum vBulletinReplies: 5Last Post: 22nd Dec 2010, 03:59 PM -
Get RSS of category ?
By chipve in forum Webmaster DiscussionReplies: 3Last Post: 16th Oct 2010, 05:24 PM -
XXX category
By Pirate in forum Webmaster DiscussionReplies: 9Last Post: 26th Sep 2010, 06:30 PM
themaManager - edit and manage...
Version 4.04 released. Open older version (or...