In my wordpress template I am changing div class according to wordpress option setting values. I have multiple template /pages , so instead of repeating the php code on each template page, I want to create a function to return variable css class( $div here).
Wordpress option setting gives 2 variables: $pagewidth & $pagecolor.
PHP:
<?php
$pagewidth = 'big'; //big,small or tinny
$pagecolor = 'white'; //white or black
$divclass = array();
$divclass = array($pagewidth,$pagecolor );
$div = $divclass['0'].'-'.divclass['1'].'-box';
?>
css:
.big-white-box{width:100%;height:100%;background:url(images/big-white.png) repeat;}
.big-black-box{width:100%;height:100%;background:url(images/big-black.png) repeat;}
.small-white-box{width:100%;height:100%;background:url(images/small-white.png) repeat;}
.small-black-box{width:100%;height:100%;background:url(images/small-black.png) repeat;}
.tinny-white-box{width:100%;height:100%;background:url(images/tinny-white.png) repeat;}
.tinny-black-box{width:100%;height:100%;background:url(images/tinny-black.png) repeat;}
HTML:
<div class="<?php echo $div; ?>" >
<!--content-goes-here--->
</div>
Help me to create a php function which return css variable $div.
width:10o%;in your code and notwidth:100%;make sure you correct it in your css - Karan Thakkar