Hi I'm using the standard way to load styles and scripts within my plugin. But I have no clue why it's not working. It's not shown in the network tab nor in the <head>. Can this cause issues when overriding templates?

add_action('wp_enqueue_scripts', 'add_styles_scripts');
add_action('admin_enqueue_scripts', 'add_styles_scripts');

function add_styles_scripts()
    wp_enqueue_style('rs_css', plugin_dir_url(__FILE__) . 'style/default.css', array());
    wp_enqueue_style('rs_fullscreen_css', plugin_dir_url(__FILE__) . 'style/fullscreen.css', array());
    wp_enqueue_script('rs_js', plugin_dir_url(__FILE__) . 'style/default.js', array('jquery'));
    wp_localize_script('rs_js', 'wordpress_data', array('ajax_url' => admin_url('admin-ajax.php')));

add_filter( 'template_include', 'render_custom_template' );

function render_custom_template( $template )
  • 1
    which file is this in? Have you verified directly that the add_styles_scripts function runs via the error log breakpoints or a wp_die? Is the file this code is in also the root plugin file with the plugin header comment at the top? Or is it a different file? What does the rest of render_custom_template contain, and are you calling the necessary functions in that template such as wp_head() etc?
    – Tom J Nowell
    Commented Nov 10, 2022 at 15:20
  • 1
    For reference, as long as your template is well built then all things that happen in the header should happen in the header. Using template_include wouldn't cause this, it's more likely to be a problem with running the code to enqueue, getting the right file enqueued, or not calling the necessary mandatory functions in the template ( aka WP knows what to enqueue but never has the opportunity to do it )
    – Tom J Nowell
    Commented Nov 10, 2022 at 15:23
  • Your code works. Are you sure you have included the code file? Commented Nov 12, 2022 at 16:20

1 Answer 1


The fix was really easy. The template I was trying to load, did not have wp_head() in it. So ofcourse no JS/CSS was loading in. Thanks for the help everyone!

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.