I need help to dynamically add an onload function to the body tag

admin

Administrator
Staff member
I am having trouble having to if statements on my body tag. The if statement i currently have is wordpress function:

Code:
<?php echo is_single() ? "<body class='single'>" : "<body>" ; ?>

This works fine. The problem is on 1 page I need to have "".
So what I did was wrap this in another if statement like so:

Code:
<?php if(is_page('map')) : ?> 
<?php echo "<body onload="initialize()">" ; ?>
<?php else : ?>
<?php echo is_single() ? "<body class='single'>" : "<body>" ; ?>
<?php endif; ?>

Apparently my syntax is wrong on the 2nd line, but I can't see why?

Can anyone see where I have gone wrong? Or is there an easier way to achieve this in wordpress?

Thanks in advance,
Dean