0

I'm creating a Wordpress theme with an admin panel and I would like to put bootstrap switch and bootstrap sliders like:

enter image description here OR enter image description here

But the problem is that I find the scripts in the page correctly added but nothing happen. I have the scripts enqueued like this:

add_action('admin_enqueue_scripts', 'load_admin_scripts');
function load_admin_scripts( $hook ){

if($hook == 'toplevel_page_boon_theme'){
        //Slider
        wp_enqueue_script('bootstrap-slider', get_template_directory_uri() . '/js/bootstrap-slider.min.js', array('jquery'), '1.0.0', true);
        wp_enqueue_style('bootstrap-slider', get_template_directory_uri() . '/css/slider/bootstrap-slider.min.css', array(), '1.0.0', 'all');

    }
}

In the files of the page I find correctly this scripts but when I try to slide nothing happens.

I have the input like this:

<input id="ex6" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="3"/>

And in the javascript I have:

jQuery(document).ready(function ($) {
    //Slider Bootstrap header
    $("#ex6").slider();
});

It creates inside the input a span like this:

enter image description here

But the input that I show is an usual input: enter image description here

I don't know what I am doing wrong but I know it can be possible because I have shown in another themes.

Thanks a million for the help.

Ary
  • 462
  • 1
  • 5
  • 16
  • bootstrap-slider.min.css not included properly. Please bootstrap-slider.min.css file included in your page – Vel Nov 29 '16 at 10:10
  • Why is not included properly? I saw in the page files @vel – Ary Nov 29 '16 at 10:17
  • what is the error on console? – Vel Nov 29 '16 at 10:36
  • remove this condtion and check if($hook == 'toplevel_page_boon_theme'). – Vel Nov 29 '16 at 10:36
  • There is no error in console, it's that the slider doesn't appear. I don't want to remove this line because if I remove it all the scripts are included in all pages and it is not fine. The other scripts are added correctly like this one but the problem is that is not working the javascript because the slider or the switch don't appear – Ary Nov 29 '16 at 10:45
  • add boostrap css in this hook function adminfooter() { } add_action('admin_footer', 'adminfooter');. you can remove later. – Vel Nov 29 '16 at 10:52
  • @vel it doesn't work. Now the css is not in the head of the page. In the other way it is there. – Ary Nov 29 '16 at 10:56
  • This is works for me if($_GET['page']=='your_page'){ wp_enqueue_style("boostrap", $themeurl."/css/responsive-tabs.css", false); } – Vel Nov 29 '16 at 11:01
  • http://wordpress.stackexchange.com/questions/51023/add-header-and-footer-to-wp-backend – Vel Nov 29 '16 at 11:11

0 Answers0