Reputation: 45
I activated an option to display a short description on my WordPress site. The thing is that I want this description only on 1 page but it displays on all of the pages.
So I added this CSS:
.page-id-1234 {display: none;}
on the pages that I don't want my text to display on. But my question is:
Is there a way to hide this text on every page except the one that I want it to display on, instead of putting display: none;
on all of my other pages?
Upvotes: 0
Views: 3069
Reputation: 2988
If you want to display it on just one page then you can use :not()
css selector
:not(.page-id-1234) {display: None;}
This way it will be hidden on every page which does not have .page-id-1234
class.
Upvotes: 1
Reputation: 115350
Since every page has a specific ID you would have to set the elements default display
property value to none
and override this for your specific page ID.
So let's say your element has an ID of #description
You would set this to
#description {
display:none;
}
then add a line referencing the page ID as higher specificity selector and change the display property as required
#page-id-1234 #description {
display:block;
}
Upvotes: 1