Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Possible Duplicate:
Load js/css files only on specific admin UI pages

If anyone knows that how to include JS Or CSS file in plugin page of wordpress, then tell me fast.

Thanks in advance

share|improve this question
How are you adding the page? Put the code here. – Rutwick Gangurde Jun 25 '12 at 12:56
On what page? On a front-end page with a specific ID? On a page with a specific short-code? Or is this a custom admin page? – Stephen Harris Jun 25 '12 at 13:12

marked as duplicate by Chris_O, toscho Jun 25 '12 at 13:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

use wp_enqueue_script(); to call js and wp_enqueue_style(); for css

e.g let say your js file is called script.js

on your plugin page put

function you_fancy_js(){
wp_enqueue_script('myscript', plugin_dir_url(__FILE__). 'script.js');
wp_enqueue_style('mystyle', plugin_dir_url(__FILE__). 'style.css');
}
add_action('wp_enqueue_scripts','you_fancy_js');// load js in non-admin pages
add_action('admin_head','you_fancy_js'); //load js in admin page.
add_action('wp_enqueue_styles','you_fancy_js');// load css in non-admin page
share|improve this answer
2  
Note: this will load the script on all pages. Also you should use admin_enqueue_scripts rather than admin_head. – Stephen Harris Jun 25 '12 at 13:10
that is correct stephen. – Ronny Jun 25 '12 at 13:12
+1 @StephenHarris That is why I asked the question poster how he is adding the page. – Rutwick Gangurde Jun 25 '12 at 13:15

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