Question

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.

Was it helpful?

Solution

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;.

OTHER TIPS

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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top