I have an if statement which shows a countdown only on Sundays and Wednesdays. But, I need to add padding to the body as well for it to display correctly.
So basically I need to add padding to the body when a line of php is executed.
Is this possible?
To keep your styles and HTML separate, you can add a class to the body based on the same if statement. Then use your CSS to add styles to that class:
<?php
$dayOfWeek = date( "w", $timestamp);
if ($dayOfWeek == 0 || $dayOfWeek == 3) { ?>
<body class="withCountdown">
<?php } else { ?>
<body>
<?php } ?>
body.withCountdown {
padding: 10px;
}
(Excuse my rusty PHP syntax!)
<body style="padding:<?php echo(is_sunday() ? '4px' : '0' );?>" >