Paste in your code snippet and save your changesĪnd that’s it! How To Add PHP Code Snippets With Code Snippets Pluginįor code snippets that aren’t theme specific, you can use the aptly named Code Snippets plugin.Choose the functions.php file under the Theme Files column.FTP lets you quickly fix things).īut if that’s confusing, you can also do it right from your WordPress dashboard: If you’re familiar with FTP, I recommend doing this via FTP for the safest approach ( sometimes you might accidentally mistype the code, which can cause problems on your site. Now, all that’s left to do is add the code snippet(s) to the new functions.php file in your child theme. Step 2: Add Code Snippets To functions.php File Then, click the Activate & Publish button to activate your child theme: Click the Childify Me button at the bottom.Scroll down the left sidebar of the WordPress Customizer.Go to Appearance → Customize in your WordPress dashboard.Install and activate the Childify Me plugin.While it’s possible to manually create a child theme, to simplify the process you can use a free plugin called Childify Me. But it will allow you to safely make new changes without the danger of those changes getting overwritten the next time you update your theme. Otherwise, let’s start at the beginning… Step 1: Create A New Child ThemeĪ child theme won’t affect any of the current functionality on your site. If you already have a child theme, skip ahead to Step 2. Paste in the code snippet – this part is pretty easy!.Create a child theme ( if you don’t already have one ) – this ensures that the code snippets you add aren’t overwritten the next time you update your WordPress theme.Sound good? Let’s jump into the specific methods… How To Add Code Snippets To Child Theme’s functions.php FileĪdding code snippets to your functions.php file is fairly simple. If the functionality you’re adding needs to continue to work even if you switch WordPress themes, add it via the plugin method.If the functionality you’re adding ONLY applies to your current theme, add it directly to your child theme’s functions.php file.So here’s a quick rule of thumb for where to put PHP code snippets: ![]() On the other hand, if you add your code snippet to a plugin, it will remain there no matter which WordPress theme you’re using. If you add the code snippet directly to your theme, that snippet will stop working if you ever change WordPress themes. While both approaches end with the snippet being added to your WordPress site, there are some functional differences, namely this:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |