some code goes here
As for where the code goes, that’s inside the functions.php file in your WordPress theme folder after you access your WordPress website via FTP. The position depends on the use case:
1. Place the code in the header or footer
Note. The number 15 is an example of a page ID we taught you to find already.
Note. Once again, 18 represents the ID, only this time of a post rather than a page. You can use method 1 (going to Posts > All Posts instead) or method 3 in the page ID guide to discover it.
1. Anywhere on the website
DIY (Do It Yourself) method
- Install one of the WordPress plugins from the repository.
- We’ll use the most popular one, Simple Custom CSS and JS for demonstration purposes.
- In the left sidebar of the WordPress Admin Section, click on Custom CSS & JS.
- Click on Add Custom JS below the option above or the Add JS Code button in the top left corner.
- Give it a title, paste the code in the text field.
- Select the position, visibility, and other configurations under “Options” in the right-hand menu.
- Click on Publish.
- If you don’t see the changes immediately, clear your WordPress site cache.
2. Header or footer
3. Inside posts and pages
- Install a plugin for this purpose. We’ll use Code Embed by David Artiss, which we aren’t affiliated with, but perfectly illustrates our point.
- Click on Screen Options in the top right corner.
- Put a checkmark in front of Custom Fields.
- Scroll down and click on Enter new in the “Custom Fields” meta box.
- Enter the name for the code under “Name”. Keep it short but unique.
- Click on Add Custom Field.
- Note. Replace Name with the actual name you chose in step 5.