Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brycejacobson/6062232 to your computer and use it in GitHub Desktop.
Save brycejacobson/6062232 to your computer and use it in GitHub Desktop.
Load custom scripts on specific pages in WordPress using Genesis.
<?php
//* Do NOT include the opening php tag
/** Load scripts on Portfolio page */
add_action('genesis_after_footer', 'child_load_portfolio');
function child_load_portfolio() {
if(is_page('Portfolio')) {
wp_register_script( 'isotope', get_bloginfo('stylesheet_directory').'/lib/js/jquery.isotope.min.js' );
wp_enqueue_script ( 'isotope' );
}
}
/** Isotope vars */
add_action('genesis_after', 'child_script_portfolio');
function child_script_portfolio() {
if(is_page('Portfolio')) { ?>
<script type="text/javascript">
var $container = $('#container');
// initialize isotope
$container.isotope({
layoutMode: 'fitRows',
});
// filter items when filter link is clicked
$('#filters a').click(function(){
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
return false;
});
</script>
<?php } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment