Here is the index.php and desktop.php of my wordpress installation. I'm loading desktop.php into #tLoad if browser window width is larger than 800px. So far so good. But I want to load it with a php echo. And in the desktop.php I want to use etc, but it's not working either. I get an error that says "Fatal error: Call to undefined function.." and so on. I understand that I probably have to use AJAX calls of some kind, but I can't figure it out..
How can I make the php functions work inside the script and desktop.php?
<?php
/* Template Name: Start */
?>
<?php get_header(); ?>
<script type="text/javascript">
$(document).ready(function() {
function o() {
if (ww > 800) {
if ($.browser.device == false) {
e.load(n);
} else {
e.load(r);
}
} else if (ww < 800) {
e.load(r);
}
}
isHome = true;
var e = $("#tLoad"),
// This is the first php echo that's not working (I have to put in the direct url to make it work):
n = "<?php echo get_template_directory_uri(); ?>/desktop.php",
r = "<?php echo get_template_directory_uri(); ?>/mobile_v.php";
$(window).resize(function() {
ww = win.width();
o()
});
o()
});
</script>
<div id="tLoad"></div>
<?php get_footer(); ?>
desktop.php:
<?php the_content(); ?>