Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created May 31, 2016 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/b1fcdde715fed1d4dd72fc4c0fea0b9c to your computer and use it in GitHub Desktop.
Save billerickson/b1fcdde715fed1d4dd72fc4c0fea0b9c to your computer and use it in GitHub Desktop.
<?php
/**
* Javascript for Load More
*
*/
function be_load_more_js() {
global $wp_query;
$args = array(
'nonce' => wp_create_nonce( 'be-load-more-nonce' ),
'url' => admin_url( 'admin-ajax.php' ),
'query' => $wp_query->query,
);
if( is_home() )
$args['context'] = 'home';
elseif( is_single() )
$args['context'] = 'single';
else
$args['context'] = 'archive';
wp_enqueue_script( 'be-load-more', get_stylesheet_directory_uri() . '/js/load-more.js', array( 'jquery' ), '1.0', true );
wp_localize_script( 'be-load-more', 'beloadmore', $args );
}
add_action( 'wp_enqueue_scripts', 'be_load_more_js' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment