I would like to localise the ajaxurl for the plugin Ajax Load More - Infinite Scroll:

/* <![CDATA[ */
var alm_localize = {“ajaxurl”:”http:\/\/siteurl\/test\/wp-admin\/admin-ajax.php”,”alm_nonce”:”0dge8w13b3″,”pluginurl”:”http:\/\/homeurl\/test\/wp-content\/plugins\/ajax-load-more”,”scrolltop”:”false”};
/* ]]> *

How can this be achieved?

Thank you


I have come up with this:

 $localiser = array(
        'ajaxurl' => admin_url( 'wp-admin/admin-ajax.php' ),
      wp_localize_script( "ajax-load-more", "alm_localize", $localiser );

How do I register the plugin js? In Load More case, what do I have to register? the main ajax-load-more.js in /core/js in the plugin folder?


You can achieve this using wp_localize_script

$myData = array(
    'ajaxurl' => admin_url( 'admin-ajax.php' ),
wp_localize_script( "myScript", "alm_localize", $myData );

NOTE: myScript should be the handle of a script which has been registered using wp_register_script

| improve this answer | |
  • what is the handle for Ajax Load More? – paranza Jan 20 '17 at 14:21
  • handle for ajax load more? – Tunji Jan 20 '17 at 14:25
  • yeah, I am looking at the plugin and I am not sure what is the handle for the ajax load more. My difficulty is to understand what I should call. Thank you for your help. – paranza Jan 20 '17 at 14:37
  • I think I got it, the script should be ajax-load-more for that plugin – paranza Jan 20 '17 at 15:06
  • Do I need to register the actual ajax-load-more.js? – paranza Jan 20 '17 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.