admin管理员组

文章数量:1425783

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=".3.1/jquery.min.js"></script>

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

Thanks.

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/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

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

Thanks.

Share Improve this question edited May 30, 2019 at 11:40 Shaun21uk asked May 30, 2019 at 10:16 Shaun21ukShaun21uk 311 silver badge8 bronze badges 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 Commented 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/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 Commented 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 Commented May 31, 2019 at 5:30
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: javascriptHow do I integrate a codepen