Site logo

Archived topic

About adding html/css/JavaScript code to my GP website

1 reply · Started by Tom on December 24, 2021

Viewing posts 1–2 of 2

Hello

For inserting a complete code(Accordion function), I can insert a complete html code(mix html/css/JS) into Gutenberg container.

Is there any other way to adding codes more "Simple" and "Professional"?

I tried below:

Step 1: Insert a short pure html code into a container. Anchor this container a name "db-bw-accordion"
Step 2: Insert CSS code in customization or SIMPLE CSS
step 3: Use hook to add JS code to a position of one page or whole site. Problem came: I can't make it correct!

Below is the Accordion codes I found:
https://www.w3schools.com/howto/howto_js_accordion.asp

Can I get a guide on this?

Many thanks!

Tom

Hi there,

in Step 3 using the Hook.

1. Make sure the JS is wrapped in <script> tags eg.

<script>
The javacsript here
</script>

2. Select the wp_footer hook. This will make sure the script fires after the HTML has loaded on the page.

This archived topic is closed to new replies.