0

EDIT: Answered own question with some fiddling around

Bit of a newbie question but sure someone here can help:

I am simply rubbish with JS but am learning on my feet.

I have created a simple codepen and want to use it in certain custom pages on my wordpress site.

The question is - how and where do I add the JS portion so that my site recognises it?

Also, at the bottom of the HTML portion is says:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

....which I assume will need to be added somewhere too?

Thanks.

3
  • Stylesheets and scripts are necessary to your pen to work correctly. and wordpress have it's own way to inject script/style files called enqueuing. but in this case jQuery is already loaded by wordpress so you don't need to include jquery
    – Vishwa
    May 30, 2019 at 10:59
  • I see, so I can live without that line. So the css portion also seems to reference: maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css I added this to my child theme functions.php as enqueue and it has broken my site. Man it seems like it should be such a simple task :/
    – Shaun21uk
    May 30, 2019 at 11:01
  • Actually, it is.. it'll be even more simple once you get the hang of it. good luck :)
    – Vishwa
    May 31, 2019 at 5:30

1 Answer 1

0

All sorted.

My theme actually had a section for custom javascript in the theme options.

I added the code there and used the enqueue for the bootstrap - all working fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.