evgenyp
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Add `wp_localize_script` to the file, not inlineI use 52 fields in the right place in the custom post output on the front end. All those 20 posts use custom post types.
And I usewp_localize_script( 'my-scripts', 'myOptions', $context['options'] );for the only reason – have an access through the objectmyOptions.So data is in DB, it’s static.
I didn’t to mention that I use Timber, don’t know if it’s matter.// add fields from options page $context['options'] = get_fields( 'options' );// add site options to combined js file wp_localize_script( 'my-scripts', 'myOptions', $context['options'] );Forum: Developing with WordPress
In reply to: Add `wp_localize_script` to the file, not inline@joyously could you explain, please, how can I get this.
Probably, you have useful links.
My Custom Post type contains 52 fields
And I have 20+ posts that use that CPT. So I have a big volume of data.
And I don’t understand what should I do in php and javascript file.
Sorry, i really confused.
Appreciate your tips.Forum: Developing with WordPress
In reply to: Add `wp_localize_script` to the file, not inline@joyously The data is not dynamic. I mean, i filled it’s in a Dashboard, saved and that’s it.
If it’s not dynamic data, why isn’t it in a file already?
Because I wrote earlier, what method i’ve used to add the data –
wp_localize_script
To have an access to the data I used this method and createdmyOptionsobject to access data.
What can I use instead?- This reply was modified 5 years, 8 months ago by evgenyp.