<?php
if ( is_home() ) {
?>
<script type="text/javascript">
if ($(window).width() < 768) {
document.write("<?php echo do_shortcode("[mobile-slider]"); ?>");
} else {
document.write("<?php echo do_shortcode("[desktop-slider]"); ?>");
}
</script>
My homepage renders and displays "); } else { document.write("
then the homepage slider and then "); }
. Any idea why?
JS error
SyntaxError: unterminated string literal
document.write("
HTML Output - Seems to be adding a line break which I think is breaking the script?
<script type="text/javascript">
if ($(window).width() < 768) {
document.write("
<!--slider-->
How can I get this to still run even though there is a line break after the document.write("
opening?
I have also tried the following however it still prints the } else {
on screen.
<script type="text/javascript">
if ($(window).width() < 768) {
<?php echo do_shortcode("[mobile-slider]"); ?>
} else {
<?php echo do_shortcode("[desktop-slider]"); ?>
}
</script>