Trying To Do This – Please Help
-
I’ve written a few plugins so I know my way around WordPress, but I’m trying to do something just now and have a lot of trouble with it.
I want to include some javascript code on every page that includes a shortcode. I’m currently attempting it using this code:
<?php add_shortcode('theshortcodehere', 'wbbb_shortcodes'); function wbbb_shortcodes($atts){ return 'Hello There.'; add_action('wp_head','wbbb_echohead'); } function wbbb_echohead(){ echo '<script type="text/javascript"><!-- Lots of JavaScript here--></script>'; } ?>
So what should happen is the shortcode should activate the wbbb_shortcodes() function which in turn adds the javascript wp_head action. Unfortunately it doesn’t trigger. The shortcode works and returns Hello There. but the javascript isn’t included in the head section (I am viewing the generated HTML source).
What am I doing wrong, or is there an easier way to accomplish this?
Cheers
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Trying To Do This – Please Help’ is closed to new replies.