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:
- in
admin_load_scripts
parse parse$_server
, depending on current url attachjs
file need. - 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
Post a Comment