Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    What is the code you are using?

    Thread Starter codeguerilla

    (@codeguerilla)

    function add_required_scripts() {
       // register your script location and dependencies
       wp_register_script('customscripts', '/get_stylesheet_directory() . /js/bootstrap.min.js', array('jquery'));
       wp_register_script('flexslider',  '/get_stylesheet_directory() . /jquery.flexslider-min.js', array('jquery'), '2.1');
       // enqueue the script
       wp_enqueue_script('customscripts');
       wp_enqueue_script('flexslider');
    }
    add_action('wp_enqueue_scripts', 'add_required_scripts');

    Pretty much the same for the stylesheets just using wp_enque_style()

    For the sake of getting things done I currently replaced the calls to get_stylesheet_directory() with the actual path, ie: https://localhost/clients/myclient/js/flexslider.js which loads the scripts and has allowed me to keep working but obviously this is not the best solution.

    thanks

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Get rid of the quote and slash before the function. It should be:

    wp_enqueue_script( 'custom-script', get_stylesheet_diretory() . '/js/file.js', array( 'jquery' ) );
    Thread Starter codeguerilla

    (@codeguerilla)

    Sorry, that was actually a typo on my part here, Like I said I am currently using the full path and replaced it so you could see my non working code. The actual code does not have those characters.

    Code is this:

    function add_required_scripts() {
       // register your script location and dependencies
       wp_register_script('bootstrap', get_stylesheet_directory() . '/wp-content/themes/twentyfourteen-child/js/bootstrap.min.js', array('jquery'));
       wp_register_script('flexslider',  '/wp-content/themes/twentyfourteen-child/jquery.flexslider-min.js', array('jquery'), '2.1');
       // enqueue the script
       wp_enqueue_script('bootstrap');
       wp_enqueue_script('flexslider');
    }
    add_action('wp_enqueue_scripts', 'add_required_scripts');

    Still returning the broken file path of:

    https://localhost/clients/buysellmyhomelaC:xampphtdocsclientsmyclient/wp-content/themes/twentyfourteen-child/wp-content/themes/twentyfourteen-child/js/bootstrap.min.js?ver=3.8.2

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    I think part of that reason is you are including the /wp-content/themes/twentyfourteen-child.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with get_stylesheet_directory using child theme’ is closed to new replies.