0

I'm facing a strange problem. After I've moved to another server, my wp_enqueue_script calls don't do anything. I do have this function:

function moemax_scripts() {
    wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.min.css' );
    wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/lib/bootstrap/js/bootstrap.min.js', array(), '3.3.1', true );

    wp_enqueue_script( 'main-js', get_template_directory_uri() . '/js/main.min.js', array(), array(), '1.0.0', true );

    wp_enqueue_style( 'moemax-style', get_stylesheet_uri() );

    wp_enqueue_script( 'moemax-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0.0', true );

    wp_enqueue_script( 'moemax-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '1.0.0', true );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

    wp_enqueue_style( 'core-css', get_template_directory_uri() . '/css/core.min.css', false, '1.0.0' );
}

The strange thing is, all my css files get included, but none of the js files are added to the site. I tried to change $handle, $ver or even $src but nothing is happening. I don't get any errors in console.

3
  • Your main-js has two array() declaration - which is wrong. It'd be helpful using the developer tool's "Console" while working with javascripts. Jan 14, 2015 at 15:21
  • Thanks for the hint. Changed that, but still no change. Javascript isn't showing up. And as I told you, my console don't show any errors.
    – Andi
    Jan 14, 2015 at 15:42
  • Put all the wp_enqueue_style() on the top, and wp_enqueue_script() below them. Jan 14, 2015 at 15:59

2 Answers 2

0

I'm not sure what the problem would be, but I'd start out by checking to see if they are actually getting enqueued.

http://codex.wordpress.org/Function_Reference/wp_script_is

That would at least let you know if you have a declaration problem of if there is something wrong when enqueued scripts are being drawn. (like a plugin conflict or some such)

0

you need to register and enqueue style / script..

wp_register_style('mystyle', plugins_url('/css/mystyle.css', __FILE__));
wp_enqueue_style( 'mystyle' );

wp_register_script('myscript', plugins_url('/js/myscript.js', __FILE__));
wp_enqueue_script( 'myscript' );
1
  • No, it is not neessary. You don't have to, you can simply just enqueue. :-) Jan 14, 2015 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.