Force Multiplier Marketing

First Class Web Design & Online Marketing Solutions

  • HOME
  • SERVICES
    • WEBSITE DESIGN
    • DIGITAL MARKETING
  • PORTFOLIO
  • TESTIMONIALS
  • CONTACT US
  • BLOG
You are here: Home » Blog » WordPress How To » Stop Editing Your Theme’s Functions File And Do This Instead

Stop Editing Your Theme’s Functions File And Do This Instead

August 1, 2017 by Rod Arnold Leave a Comment

  • Facebook
  • Twitter
  • LinkedIn

“To add this functionality, simply copy and paste the code below into your theme’s functions.php file.”

Have you ever seen this message?

When looking to add functionality to your WordPress site, chances are good that you have seen this before. However, editing your functions file can spell disaster for your site. One misplaced character and you’ll be quickly introduced to the white screen of death!

Here’s why you shouldn’t edit your WordPress theme’s functions.php file.

Your functions.php file behaves like a plugin and adds features and functionality to a WordPress site. If you’ve had the unfortunate experience of installing a “bad” plugin, you know it can break your site. The functions.php file, if edited incorrectly, WILL break your site, and unfortunately, I’m speaking from experience. For some reason, I just trusted that the author was credible and the code that I was supposed to copy and paste was correct. Doh!

You see, the functions.php file is specific to your theme. That means if you ever switch themes, all of your added functionality will be lost because you are now using another functions.php file.

Adding code to this file also adds to the file size. This file is loaded on every page and post, and it is also loaded in the admin area, so you want the functions.php file to be as streamlined as possible so that minimal time is needed to load it.

There are other reasons, but hopefully I’ve made a compelling case against editing the functions.php file for now. The good news is, there is a better way, and that’s what I’ll show you in this article.

Your Very Own (Super Awesome) Site Plugin

Since the functions.php file acts like a plugin, why don’t we just build a plugin to serve the additional features and functionality?

Wait, did you just say build a plugin? I don’t know how to build a plugin.

Well, just like Kevin Hart’s father says, “You gonna learn today”!

When we build a WordPress site for a client, this is one of the first plugins we add to their site.

Building your own site specific plugin solves the problems referenced above, and it’s surprisingly easy to do.

Really, it’s so easy, a caveman can do it!

Need To Save This For Later?

Click here and we’ll deliver this article to your inbox so that you can read it or reference it at any time.

Using cPanel

If your web hosting plan includes cPanel, then this would be the easiest way to add your own plugin. To find out if you have cPanel access, navigate to it by typing http://yoursite.com/cpanel into your browser’s address bar, replacing “yoursite.com” with your domain. If you don’t know your login credentials, you can find these in the email sent to you from your hosting provider when you signed up for their service.

1. First, locate the section named “Files” and click on the “File Manager” link.

file-manager

2. Next, select the Document Root For: and make sure your site appears in the dropdown. Select your site and click Go.

root-folder

3. Follow steps 2-6 below.

Using FTP (File Transfer Protocol)

For those of you who don’t have cPanel access to your site, or would just prefer to make changes via FTP, connect to your site, and let’s go!

1. Browse to your site’s public_html or root folder where your WordPress install resides.

2. Double click the wp-content folder and then double click on the plugins folder to open it.

plugins-folder

3. Inside the plugins folder, create a new directory (folder) and give it a name. You can name it “site-specific-functions” or something that makes sense to you.

plugin-functions-directory

4. Next, open Notepad or your favorite text editor, and create a new document. (If you are using cPanel, you can create the file within cPanel without having to use a text editor or upload the file. Look for the “New File” icon at the top.)

5. Copy and paste the code below into the document and name it “Your Site Functions.php”, or something similar. You can name it whatever you want but make sure to save the document with the .php extension or it will not work.

[php]
<?php
/* Plugin Name: Site Specific Plugin for yoursite.com
Description: Site specific code changes and additions for yoursite.com.
This is used in place of adding additional code snipets to the functions.php file. */
/* Add Functions And Code Snippets Below this Line */

/* Do Not Add Functions And Code Snippets Below this Line */
?>
[/php]

(Note: You’ll also want to edit the plugin name and the description in the code before you save the document as well, but it will work even if you don’t.)

6. Next, upload the newly created file to the folder you created. If using cPanel, simply save the file.

functions-plugin-file

All that’s left to do now is to visit your installed plugins page and activate it.

Now, when you need to add code snippets to your site, you can add them to your plugin instead of adding them to your theme’s functions.php file.

As a result, you’ll never have to worry about breaking your site again because you have now eliminated the need to edit the functions file.

See, I told you it was easy!

Did you find this helpful? Leave a comment or click a button below to share it with your friends.

  • Facebook
  • Twitter
  • LinkedIn

Filed Under: WordPress How To Tagged With: How-To, WordPress

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CONNECT ON SOCIAL MEDIA

secure & reliable web hosting

Web Hosting

watch an infusionsoft demo

Force Multiplier Marketing

WEB DESIGN & DEVELOPMENT

  • WordPress Websites
  • Membership Sites
  • eCommerce Stores

DIGITAL MARKETING

  • Marketing Funnels
  • Business Automation
  • Email Marketing | CRM

OPTIMIZATION

  • Search Engine Optimization
  • Site Speed Optimization
  • Customization Services

RESOURCES

  • Contact Us
  • Privacy Policy
  • Terms And Conditions

Copyright © 2021 · Force Multiplier Marketing · All Rights Reserved

Copyrighted.com Registered & Protected