javascript - In wordpress to attach different js files -


in wp 4.2 project attach js files like:

add_action('wp_print_scripts', array(&$this, 'admin_load_scripts')); ... function admin_load_scripts() {      wp_register_script('backendartistssongsjs', $this->plugin_url . 'js/backend-scripts.js'); ... 

but want different pages attach different js files. can in these ways:

  1. in admin_load_scripts parse parse $_server , depending on current url attach js file need.
  2. in related php file include file need.

if there better way , way prefer?

if want load script on particular page can use

<?php if( is_page('<page-name>')) { ?>     // import  <?php } ?> 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -