Style each post differently by category
Hi!
I'm trying to reach my 'ideal template' using atahualpa. The most important need I have is to mark all the post of certain category with a distinctive background color. I found this article which suggest to use the post_class PHP function. I tried to add this in ATO--->Style/edit Center Column---> The Loop before </div><!-- / Post --> PHP Code:
Code:
.category-test {background: #00ff00; border: 1px solid #84aac4;} but with no result...do you have some suggestions? thanks thanks =) |
since all the posts have a category class like 'category-uncategorized', why not use that
HTML Code:
div.category-uncategorized {background-color: blue;} |
thanks for your reply juggledad!
Surely I'm doing something wrong ... I tried adding " div.category-announcements {background-color: yellow;} " in CSS Inserts but nothing happened =( Did you mean that using div.category-name php code is not necessary? |
You need to use the names of your categories
No you don't need to add anythingng. View your page, theview the source and you should be able to find your category names. |
ouch! It works!
but only in the category page view. What I need is to have different post background only in the front-page.. uhm, |
What is the URL?
|
Quote:
and here there's the category page, where the "div.category-name" works perfectly: http://yupyup.altervista.org/?cat=8 hmmm strange... maybe I've to do this via php? with 'if is front page'? thanks and sorry for the late reply =)) |
You have code that is changing the front page from a single column to multiple columns. That code is not putting the category type of the <div> for the posts. You need to fix that for it to work.
|
Quote:
<div class="post_footer"> <p class="postmetadata"> <?php the_category(', ') ?> </div> but the problem persists.. hmmm |
Did you look at a generated page to see how atahualpa named the category classes?
|
I think I get lost... :(
|
The class name needs to be 'category-yourcategoryname' so the CSS can be applied. You are not creating that type of class name in your code.
|
I tried adding this in the Loop: <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
But the result is this: http://yupyup.altervista.org/ and no css effect. |
you are creating a mess for yourself. here is one of your posts
HTML Code:
<div id="new_central_pos_30"> you are missing a closing</div> you have the content of the post before the <div> for the post and who knows what else Custom changes like this to the theme are really beyond the scope of the forum. If you are unsure about how to do detail customization and how php/css work, you might want to put a post in the Customization, Design, Programming... section and see if you can hire some one to help you out. |
I feel sorry.
But I just used the code found here: http://forum.bytesforall.com/showthread.php?t=4220 with a small change to have only the three column part. What you saw (that huge mess :) ) happened when I added " div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> ". Now,moved away that code, the homepage looks normal. Anyway, considering the errors you reported, maybe there are problem with that code? thanks and sorry for my ignorance =) |
Hello,
I had the same question and tried to add Code:
div.category-NAME {background-color: yellow;} I then inserted a SPACE between "div" and the dot... Code:
div .category-NAME {background-color: yellow;} |
All times are GMT -6. The time now is 07:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.