WordPress Tutorial, add css and javascript file to admin in wordpress theme. Many developers want to add the javascript and css files into wordpress themes.
add css and javascript file to admin in wordpress theme
You just need to add following code into functions.php file.
// Register your javascript for properties function admin_your_javascript(){ global $post; if($post->post_type == 'post-type' && is_admin()) { wp_enqueue_script('YOUR-JS', WP_CONTENT_URL . '/themes/YOUR-THEME/js/YOUR-JS.js'); } } add_action('admin_print_scripts', 'admin_your_javascript'); // Register your styles for properties function admin_your_styles(){ global $post; if($post->post_type == 'post-type' && is_admin()) { wp_enqueue_style('YOUR-CSS', WP_CONTENT_URL . '/themes/YOUR-THEME/css/YOUR-CSS.css'); } } add_action('admin_print_styles', 'admin_your_styles');
You just need to replace Your theme name and javascript and css file name.