I have the two scripts that I need to enqueue. I'd like the child theme's script to be loaded after the Mustache template scripts. Even when specifying the priority, the child theme's script is loaded before the Mustache script.

Loading order now: load_lh_script, load_external_script

How can I correct this script loading order to be like the following?

  1. load_external_script
  2. load_lh_script

function load_external_script()
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');

function load_lh_script() { 
    wp_register_script('theme_js',get_stylesheet_directory_uri() . '/js/lh.js',array(), '1.0.0',false);

1 Answer 1


You can dequeue the parent theme's styles, and then enqueue all the styles in any order you'd require. This is how you can do it:

function remove_parent_styles() {
    wp_dequeue_style( 'sample' );
    wp_deregister_style( 'sample' );

    // Now enqueue your styles and scripts in the order you wish.
    // Just add all of them one after another.
add_action( 'wp_enqueue_scripts', 'remove_parent_styles', 999 );

We also increased the priority to make sure out hook runs after the theme's styles are queued.

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.