Answer the question
In order to leave comments, you need to log in
CSS inside PHP, how to do it right?
Site on WordPress.
On the main page, you need to add styles for the header. It is impossible in .css, because the header is on all pages, and you only need to change it on the main one.
Did it like this:
<?php if( is_home() ) { ?>
<style>
// ...
</style>
<?php } ?>
<body <?php if( is_home() ) body_class('homepage') ?>>
Answer the question
In order to leave comments, you need to log in
I suggest not to spoil the html with styles, just add a class or id to the body:
<body<?if(is_home()):?> id="homePage"<?endif;?>>
...
</body>
Move the styles to a separate file. Add a check for the page id, if this is the main one, we include the file, no, we don’t)
Router, I hope they did it to check the URI?
This is how we act!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question