How to enqueue css and js in custom template

By: Nathan Hugo | Asked: 05/22/2025
ForumsCategory: Code HelpHow to enqueue css and js in custom template
Nathan HugoNathan Hugo asked 4 weeks ago

I'm using formidable inside a plugin called woocommerce point of sale which doesn't auto load formidable forms styling and javascript, how can I load specifically the formidable css and javascript for this I've tried this:

echo "<script type='text/javascript' src='{$siteUrl}/wp-content/plugins/formidable-pro/js/frm.min.js?ver=6.21-jquery' id='formidable-js'></script>";

echo "<script type='text/javascript' src='{$siteUrl}/wp-content/plugins/formidable/js/formidable_admin_global.js?ver=6.21.1'></script>";

echo "<link rel='stylesheet' id='formidable-css' href='{$siteUrl}/wp-content/plugins/formidable/css/formidableforms.css?ver={$formidableVersion}' type='text/css' media='all'>";

echo "<link rel='stylesheet' href='{$siteUrl}/wp-content/plugins/formidable/css/admin/frm_admin_global.css?ver=6.21.1' >";

but I get errors like:

   Uncaught ReferenceError: frm_js is not defined

   at checkForErrorsAndMaybeSetFocus (frm.min.js?ver=6.21-jquery:45:214)

   at Object.init (frm.min.js?ver=6.21-jquery:56:365)

   at HTMLDocument.<anonymous> (frm.min.js?ver=6.21-jquery:68:541)

   at e (jquery.min.js?ver=3.7.1:2:27028)

   at jquery.min.js?ver=3.7.1:2:27330

:

I've also tried:

add_action('wp', function(){

     $url = getPageUrls()['url'];

     $urlInQuestion = "/point-of-sale/";

     if (strpos($url, $urlInQuestion) === false) return;

     FrmFormsController::enqueue_scripts(array('id' => 3));

});

:

But it didn't seem to do anything.

2 Answers
Best Answer
Nathan HugoNathan Hugo answered 4 weeks ago

I've created a nifty solution, although not perfect. I took the preview url and placed it inside of an iframe element:<iframe        id='updateUserFormIframe'        src='<?php echo $siteUrl; ?>/wp-admin/admin-ajax.php?action=frm_forms_preview&form=edit-user-profile'        style='width: 100%; height: 100%; border: none; position: absolute;'    ></iframe> 

Victor Font Staff answered 4 weeks ago

Did you look into any of the directories you were querying to see if the files actually exist? A few of Formidable's files are created at run time by PHP.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right