Advertise on Site! You can Advertise on our site. Find out More

add javascript and css files into wordpress theme

3 Flares Twitter 3 Facebook 0 Google+ 0 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 3 Flares ×

Many developers want to add the javascript and css files into wordpress themes. 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 javascript and css files into wordpress theme

add javascript and css files into wordpress theme

3 Flares Twitter 3 Facebook 0 Google+ 0 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 3 Flares ×
  • http://digcms.com John

    helpful information. Thanks

3 Flares Twitter 3 Facebook 0 Google+ 0 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 3 Flares ×