I have the following CSS conditional statement in my function.php file:
function logo_exists() {
global $options;
?><style type="text/css">
#header h1 a {
<?php
if ( $options['logo'] == NULL ) { ?>
float: left;
text-indent: 0;
<?php } else { ?>
background: url(<?php echo $options['logo']; ?>) no-repeat scroll 0 0;
float: left;
text-indent: -9999px;
width: 160px;
height: 80px;
}
<?php } ?>
</style><?php
}
example:
(...same code as above...)
width: 160px;
height: 80px;
}
<?php } ?>
<开发者_如何学编程/style><?php
add_option('logo_exists');
}
I'm not sure how to "add" or "initialise" it.
I tried: add_option('logo_exists'); and add_action('logo_exists'); but it didn't work.
What's the Wordpress "add" command for conditional CSS statements in the function.php file?
Instead of using this variation, you could use wordpress conditions:
is_home()
is_singular()
(for page/article) is_single()
is_page()
ad so on.
Besides that, WP automatically add an extra class to body
element and you can relate to that to build your css selectors.
精彩评论