Нужно что бы в зависимости от экрана выводил часть шаблона.
Шаблон подключается с помощью <?php get_template_part( 'desktop', 'index' ); ?>
Попытался сделать, но выводит оба варианта.
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
{
//При ширине экрана < 1280
if (screen.width < 1280)
document.write ('document.write('<?php get_template_part( 'desktop', 'index' ); ?>');');
//иначе
else
document.write ('document.write('<?php get_template_part( 'mobile', 'index' ); ?>');');
}
</script>
</body>
</html>