Today tutorial is about 3 Easy Way to Add Custom Code, Javascript, Script to WordPress. I know as a newbie WordPress player, we donât even know what is javascript or custom code. When we research to customise something that we like, many tutorial tell us to add some code, but we donât even know where to place this code. This is the problem that many people like me facing. (but obviously this is few year ago of me)
Thus, today Iâm going to teach you how to Add Custom Code, Javascript, Script to WordPress and make your WordPress website to another level.
1. Use plugin Code Snippets â add custom code to WordPress Page
The first way is simply use a free plugins call Code Snippets to add custom code to WordPress page. Code snippets is very flexible and powerful, you also can add new coding to better organise your custom code. Simply add a name and fill in your script, the plugins will do the rest.
For people who like to add some script to header & footer, just simply download this plugins name called Header & Footer it will make WordPress add script to header or footer. Other than that, you can also add some tracking code like google analytics, facebook pixel, Google Adsense or more here, Very useful!
3. Use Function.php â add javascript to WordPress
If you donât like to rely on plugins, then you can try add javascript to WordPress from Function.php. Hence, here is how you can find your function.php and placing the javascript.
- Go to file manager on Cpanel.You must access your Cpanel to do the editing, avoid directly edit those code in WordPress editor, because it will break your website.
- Find the function.php file.Path: wp-content/themes/[theThemesName]/function.php
- Paste the javascript code.No matter whatâs writing in the functions.php files just paste the code to the bottom at the last.
Related tutorial:
- How To Get Post Featured Image URL In WordPress
- How to set Html lang attribute in WordPress
- How to Change WordPress Password Protected Text without Plugins Custom for Every Page
- How to Display Last Updated Date Posts In WordPress (Stepbystep)
- How to Get Custom Field Value in WordPress (Display WordPress Custom Fields)