Menu icon Foundation
Interchange with wordpress?

I'm having trouble using Interchange.js with php fragments. I'm able to use Interchange.js easily on simple html/css projects but I can't get it to work in Wordpress when I try to use it to swap content. Has anyone had any luck with this?

    			
	<div data-interchange="[<?php echo get_template_directory_uri(); ?>/inc/default.php, (default)], [<?php echo get_template_directory_uri(); ?>/inc/medium.php, (medium)], [<?php echo get_template_directory_uri(); ?>/inc/large.php, (large)]"></div>
				            

Screenshot 2013 11 29 08.49.17

wordpressinterchange

I'm having trouble using Interchange.js with php fragments. I'm able to use Interchange.js easily on simple html/css projects but I can't get it to work in Wordpress when I try to use it to swap content. Has anyone had any luck with this?

    			
	<div data-interchange="[<?php echo get_template_directory_uri(); ?>/inc/default.php, (default)], [<?php echo get_template_directory_uri(); ?>/inc/medium.php, (medium)], [<?php echo get_template_directory_uri(); ?>/inc/large.php, (large)]"></div>
				            

Screenshot 2013 11 29 08.49.17

This post has been closed. No new replies can be added.

Steve Coates over 5 years ago

I'm a Foundation beginner and am also unable to get WordPress stuff to run like this. php will run in a file called via data-interchange but nothing WordPress...

Steve Coates over 5 years ago

OK, my clever colleague worked this out. In our scenario we're loading different php files rather than different images...

<!-- include different files depending on screen size -->
<div data-interchange="[<?php echo get_stylesheet_directory_uri();?>/partials/int-sidebar-small.php, (small)], [<?php echo get_stylesheet_directory_uri();?>/partials/int-sidebar-medium.php, (medium)], [<?php //echo get_stylesheet_directory_uri();?>/partials/int-sidebar-large.php, (large)]">
</div>

and each file needs the following to run WordPress stuff

<?php
require($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
?>

Abel Quitoriano over 5 years ago

hi Steve,

I tried implementing it like you did, but none of the template php files are loading.

  <div data-interchange="[<?php echo get_stylesheet_directory_uri();?>/parts/blogtemplate_small.php, (only screen and (min-width: 1px))], [<?php echo get_stylesheet_directory_uri();?>/parts/blogtemplate_default.php, (only screen and (min-width: 811px))]"></div>

and added

<?php
require($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
?>
 ```'

to both template files. Is there something that I'm missing?

Abel Quitoriano over 5 years ago

I found out the problem...

Since I'm on http://localhost:8888/subdomain/, wp-load.php was not found.

instead I added the subdomain to the path like so.

<?php
require($_SERVER['DOCUMENT_ROOT'].'/subdomain/wp-load.php');
?>

It's working now! thanks!