Dynamic page title color css/php
-
I’m trying to get the titles of my pages in different colors. There are just a few pages that need recoloring, the rest can be the standard css assigned color. And I don’t want the title “Home” appearing on the home page.
I think I understand that I need to start with that last bit, so the first “if” is about the homepage.
This code here has the styling and the php combined. (I copied some bits form pieces I found) But it doesn’t work, I get a php parsing error.
<?php if (!is_front_page()) { ?> <div class="post-headline"> <?php if(is_page('newsletter')) { ?> <h2> <font color="blue"><?php the_title(); ?> </font> </h2> <?php } ?><?php elseif(is_page('advertising')) { ?> <h2> <font color="yellow"><?php the_title(); ?> </font> </h2> <?php } ?><?php else { ?> <h2><?php the_title(); ?></h2> <?php } ?> </div> <?php } ?>Should I split the php and the css styling? Then the line would be something like
<titlecolor><?php the_title(); ?></titlecolor>And it would put the if/thens in the css block. That would make it a dynamic css. And I wouldn’t know how to do that.
Does anyone know how to fix my code? I really don’t know much about php, so I would be glad If you could help me.
The topic ‘Dynamic page title color css/php’ is closed to new replies.