How to Put/Send Data to CSS or JS File from WordPress Dashboard

This is could be done by many and many ways, Will give you some ideas on how that could be done:

lets start with the js data:
1- you could use the wordpress function wp_localize_script this function adds a global variable in your footer or your header and then in your js file you could use this variable.search for it and you will see many tutorials.

2- you can save your js data using normal html attributes for example in your wp dashboard you have a custom option to change slider time i will call this option my_slider_time and of course you have a custom html div for your slider in that div add html5 attribute in this way <div class="slider-holder" data-slider-time="<? echo my_slider_time ?>">
now in your js file get this attribute by using the jquery function data example: $( "div.slider-holder" ).data( "slider-time" )

for the css data read my comment on this post:

1 Like