I am having a heck of a time finding an answer to this solution. I have googled everything I can think of but I can't find anything. I want to load an inline JavaScript tag in the footer of the admin. When I use the admin_footer action, the code is added before the JS tags that are called by the wp_enqueue_script function. I need this script to be called after those scripts. How can I achieve this?

This is what I am using now:

<?php add_action('admin_footer', 'gallery_js', PHP_INT_MAX);

function gallery_js(){ ?>
        ajaxUrl: '<?php echo JZS_PLUGIN_PATH.'/admin/partials/service-gallery-ajax.php';?>'
    <?php }

See this image for a better explanation: enter image description here The image is when using the admin_footer action.

2 Answers 2


I finally found the answer. I need to use the admin_print_footer_scripts action. This will add scripts after the scripts that were called with wp_enqueue_scripts.

  • ah that hook is new to me, thanks for sharing. (set your answer as accepted)
    – Bjorn
    Jun 12, 2018 at 6:58

I did the following test:

add_action('admin_footer', 'admin_footer_test', PHP_INT_MAX);
function admin_footer_test() {

add_action('admin_enqueue_scripts', 'admin_enqueue_scripts_test', PHP_INT_MAX);
function admin_enqueue_scripts_test() {
    wp_enqueue_script( 'sq_general_js', get_stylesheet_directory_uri() . '/js/test.js', array('jquery'), '', true  );

add_action( 'admin_print_scripts', 'admin_print_scripts_test', PHP_INT_MAX );
function admin_print_scripts_test() {
    wp_enqueue_script( 'projects_portrait_slider', get_stylesheet_directory_uri() . '/js/test.js', array('jquery'), '', true  );

admin_footer is always above the script enqueue's. With admin_print_scripts you can get below admin_enqueue_scripts.

Regards, Bjorn

  • I am not enqueing a JS file. I am enqueing a JS tag. Jun 12, 2018 at 6:32
  • srry did not see the PHP and admin_footer. i'll do some testing, one sec
    – Bjorn
    Jun 12, 2018 at 6:44

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.