Jump to content

Archived

This topic is now archived and is closed to further replies.

Objectif-Mariage

How to affect Css only on posts (article), and not on pages ?

Recommended Posts

Objectif-Mariage

Hi ! 

I wish to apply a small modification on CSS, and i want to apply it to all artilces, but not to pages .....  Is it a solution for that ? 
I'have try to found some ID in the source code, but i'm not good, and I haven't found anything that's work. 

Would you have I idea ? 

the code i want to apply : 

.metamedia{background:rgba(250,250,250,0.9); padding: 3em;}

 

What I was looking for , something look's like like that : 

 

.this-is-an-article  .metamedia{background:rgba(250,250,250,0.9); padding: 3em;}

or 

#this-is-an-article  .metamedia{background:rgba(250,250,250,0.9); padding: 3em;}

 

But maybe it's just doesn't exist ? 
Have you any suggestion ? 

 

 

 

Best , 

Alex

Share this post


Link to post
Share on other sites
Danny

Hi Alex,

 

WordPress applies a unique id to all pages, posts, categories and so forth, these unique class id's can be found in the body tag. Therefore, if you want to apply specific CSS to a certain page, you will need to prefix your code with the page-id-X (replace X with the numeric id value).

For example, let's say you want to apply some specific styling to a page that has an id of 6. You would use the following code:

 

.page-id-6 .post-title { color: red; )


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Objectif-Mariage

Thank you Danny, 

I have think to that solution already, but i will have to apply it to a lot of pages :D. 
Oh well, I will see ! 

At least i now know there is no differentiation for post and page ... :(  .

 

Have a good day ! 

Alexandre

Share this post


Link to post
Share on other sites
Danny

No problem.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

×