add css and javascript file to admin in wordpress theme

add css and javascript file to admin in wordpress theme

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.

add css and javascript file to admin in wordpress theme
add css and javascript file to admin in wordpress theme

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “add css and javascript file to admin in wordpress theme”

Leave a Reply to John Cancel reply

Your email address will not be published.