Hi, currently we can add js and css from the front end . BUT this only used for front view display.
When editing the post, the js is not applied. this cause big confusion.
an example here:
i added js to check/auto select related checkboxes in the custom search form, i would like to use it at the backend as well but i cant .
is there any way of doing this ?
thanks.
I am not sure I can follow.
1. CSS and JS you add to a view, will be used solely when that View is seen in the FrontEnd.
2. The same is valid for Content Templates.
3. When you use Layouts, you can use the Layouts JS/CSS menu, where the code will be applied everywhere where a layout is used.
4. You cannot display Views or Content Templates in the backend, hence bringing it's CSS/JS to the backend is obsolete.
5. You can add Custom CSS to the Edit MetaBoxes of Types Fields, in the backend, but this is a deprecated method.
Nonetheless you can still do it by following this DOC:
https://toolset.com/documentation/user-guides/css-styling-for-fields/
Generally in WordPress CSS and JS is intended to be added in the Front End.
Hi Beda.
basially i have a simple script that auto select related checkboxes [ manually coded] . its for custom search purpose.
i am looking any way that i could have this script action running at the backend too so that its sync both way .
example custom field
Fruits -
- apple
-banana
Cars
-Lexus
-BMw
my script does this. once selected "fruits", apple and banana got selected - this is for search form.
i would like to have the same at the post edit at the both front end and backend,
pls let me know if you need more informations.
some links :https://stackoverflow.com/questions/3326967/how-to-add-custom-javascript-to-wordpress-admin
I understand.
Then you need to pass your Custom Code to the admin.
As in the StackOverflow you shared Tim explains, you need to use admin_enqueue_scripts().
This hook allows you to add your Custom Code to the admin - you need to do that in your Theme Files, this is not related to Toolset.
In the FrontEnd, I assume you will use Toolset CRED - hence you can add the script to the JS section of your CRED forms.
Please let me know if you have more doubts?
OK. thanks. ill try the admin enque and feedback soon.
Thank you for sharing those.
Yes, this is the correct API to follow when you want to enqueue things in the backend.
But, this is not related to Toolset, per se, as you cannot enqueue the Content Template or Layouts CSS in the backend, natively.
Those are intended to be in the front end.
I do suggest that you create a separate sheet with the CSS and enqueue it from the Theme, as example.