Javascript in short code not working
-
So I’ve been asked to insert a javascript widget for a job posting site on a single page with in our wordpress website.
This is the script code
<script type="text/javascript" src="https://www.ziprecruiter.com/jobs-widget/v1/7d9477b9?show_posted_days=0"></script><a href="https://www.ziprecruiter.com" id="jobs_widget_link">Powered by ZipRecruiter</a>
I created the shortcode in functions.php. It looks like this
function jobpost_func( $atts ){ return '<script type="text/javascript" src="https://www.ziprecruiter.com/jobs-widget/v1/7d9477b9?show_posted_days=0"></script><a href="https://www.ziprecruiter.com" id="jobs_widget_link">Powered by ZipRecruiter</a>'; } add_shortcode( 'jobpost', 'jobpost_func' );
and added this on the test page I am trying to create
[jobpost]Only the link shows. So to test if it was just the javascript it didn’t like I tried this in the short code instead.
function jobpost_func( $atts ){ return "<script>alert('hello world');</script>"; } add_shortcode( 'jobpost', 'jobpost_func' );
The Hello World works! I’ve been working on this for days now and tried a lot of different suggested approaches. This is the closest I have gotten. Is there something I am missing? Please help.
- The topic ‘Javascript in short code not working’ is closed to new replies.