Right way to enqueue programatically?
-
I am adding a slider to my post template.
I have added the slider to a template_part in its own directory.
I only want to enqueue the slider’s javascript and css if that post has either a featured image, or a gallery (I use ACF to add the gallery to the post).
In the single template, I get_template_part(post-slider) if there is a featured image/gallery on that post.
Where is the best place to add wp_enqueue_script (the slider’s stuff)?
Is it safe to add it in the template_part that holds all of the sliders code?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Right way to enqueue programatically?’ is closed to new replies.