Using header() with wordpress enqueue

I’m basically trying to make my js and css files dynamic. I’ve tried a few different ways of doing this and it isn’t seeming to work for me. Any help would be greatly appreciated!

functions.php

Read More
function fnp_add_js() {
    //I've tried fnp_jquery.js.php fnp_jquery.php and fnp_jquery.js
    wp_register_script( 'fnp_jquery', plugins_url( 'fnp_jquery.js.php', __FILE__ ));

    wp_enqueue_script('fnp_jquery');
}

base.php

add_action('wp_enqueue_scripts', 'fnp_add_js');

jquery.js
(I’ve tried fnp_jquery.js.php fnp_jquery.php and fnp_jquery.js)

<?php 
header('Content-type: text/javascript');

//I've also tried surrounding $(document).ready(function() {}  with echo ''; 
?>

$(document).ready(function() {
   //Javascript here
});

Related posts

Leave a Reply

1 comment

  1. What is your problem exactly, your script doesn’t get enqued, it doesn’t get served correctly?

    Fireup firebug or whatever console you are working with in your browser (usually F12) and look in the network tab if the header is really pushing out text/javascript and if the content is really there.