How to hide div on only one page

I’d like to hide a div on the front page of my site (it’s WordPress but I’ve made the home page static). I’ve been trying different things for an hour thinking it should be simple. This is what I’m using:

.page-id-2 #boxmenu {display:none;}
I also tried this:

<div class="<?php if (!is_page('2')) : ?>boxmenuhidden<?php else : ?>boxmenu<?php endif; ?>">

where “boxmenuhidden” had the display:none; attribute.

The page is here:
Any ideas what I’m doing wrong?

I think when you went from WordPress to static, you lost the additional post classes WP automatically adds to the body (.page-id-2, .page, etc).

In this case, you can only really do:

#boxmenu {display:none;}

since .page-id-2 isn’t applied.

Or maybe even:

.welcome #boxmenu{display: none}

Thanks I will give that a try after dinner!

The problem is that your #boxmenu CSS is for IDs. Not classes. Look at the code you posted in post #1. That’s assigning a CLASS. So your code from post1 needs to be changed to ID. Or your CSS changed. One or the other.

1 Like

That did it! Thanks so much! How did you know it was .welcome, though, so I know for future?

Thank you to Ryan also!

Look at the class that is put on <body>

Okay, thank you :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.