Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

how can I delete a background for #main only on my posts. I know that I have to create a conditional if statement in my functions.php file with if (is_post()) but I'm just not sure how to write it.

share|improve this question
    
what are you trying to do exactly ? i am guessing you want a different style for the div#main for pages and a different style for posts right ? –  Xavier Apr 7 '11 at 22:41
    
correct. I need a background of none or transparent. –  chris_s Apr 7 '11 at 23:11

2 Answers 2

up vote 1 down vote accepted

Take a look at the classes offered by your body_class() function to your <body> element. Then overwrite your div with the ID #main on your posts page with a higher specifity and set this div to display: none;.

share|improve this answer
    
this worked perfect. thanks. –  chris_s Apr 8 '11 at 0:25

Hello Chris here is how i propose you do it;

markup (HTML / PHP)

<div id="main" class="<?php if(is_single($post)) { echo 'post'; } else { echo 'page'; }; ?>">

css

#main .post
{
    background:none;
}
#main .page
{
    background:#CCC;
}

Basically the code checks to see if the post is a "single post" and if true it returns the class="post" if not it returns the class="page";

Add the markup to the place you are trying to put this into effect i.e. your template file.

This should do what you want it to do :)

share|improve this answer
    
If the class and ID apply to the same element they shouldn't have a space between them, eg. #main.post.. –  t31os Apr 9 '11 at 14:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.