Adding block to header
-
I’m building a plugin that uses a shortcode to display a map and list of locations. Part of displaying that list of locations requires a handlebars.js template.
That template exists as a <script> block in the <head>. It works fine when I use
add_action('wp_head', 'template_locations'); function template_locations() { echo "<script id="locations" type="text/x-handlebars-template">...." }
but not when it is called in the shortcode handler. The idea is, I only want that block to be in the head in posts where that shortcode is present.
I’ve been able to register other scripts in the plugin and then having them enqueue as part of the shortcode handler so that they are only loaded when a shortcode is present. My question is, how would I register/enqueue a <script> block in the same way?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Adding block to header’ is closed to new replies.