Modify custom_functions.php and custom.css DIYtheme files

DIY Thesis Theme for WordPress is an awesome framework for WordPress that provides excellent web site customization flexibilities.  One cool feature allows users to modify  custom.css and custom_functions.php files via text editor that gives almost limitless possibilities in terms of design and functionality. Although there are number of other excellent fram

But the ease of which a user can  make changes to these two files can be a double-edged sword.  Especially if one makes a single typo in the custom_functions.php file which can instantly disable the entire sit.  Furthermore, if a person makes a change that causes a fatal error, the user may not be able to correct it using the WordPress application.

In this post, I will outline detailed steps to minimize the risk and what to do about it should you encounter that problem.

Back up custom_functions.php and custom.css files

Because there are many variations between hosting providers and graphical user interfaces, I am going to assume the following:

  • You have WordPress v3.1 or higher;
  • You have DIYtheme v1.8 or higher;
  • You have access to your hosting server via cpanel;
  • You can use cpanel file manager to access web files;

Step 1: Login to your host via cPanel (fig 2.1)

Step 2: Click on the File Manager icon (fig 2.2)

Step 3: If you have multiple domains associated with your cpanel, choose the appropriate domain (fig.2.3).  By the way, you will note that by “GO” button is grayed out.  That is because my account access timed out when I took this screenshot.  Simply log out and log back in and you will be able to click on the “GO” button.

fig 2.1-cpanel

fig 2.2-file manager

fig.2.3-select domain

Step 4:  Navigate to this path (“public_html/“).  Please note that cPanel file manager works slightly different than that of Windows Explorer.  To drill down the file directory, you need to click on the folder icon (fig.3.1.A).  Clicking on the file or directory name allows you to change the name of that file/directory (fig.3.1.B).

Step 5:  Create a backup directory called backup-20120204 by first clicking on the New Folder icon (fig.3.2.A) then completing the name field (fig.3.2.B).  Because I frequently change my custom_functions.php and custom.css files, I use a date (yyymmdd) format for my own tracking needs but obviously you can choose any naming convention to suit your needs

Step 6: While holding down the CTRL button, click on the custom.css and custom_functions.php files (fig.3.3). While still holding the CTRL button, drag the highlighted files into the newly created backup directory. 

Please note that dragging and dropping the highlighted files while pressing down the CTRL performs a COPY function.  If you were to do this step without pressing down the CTRL key will instead perform a MOVE function.





Modifying custom_functions.php

There are two ways to modify a custom_functions.php file.   You can do it directly through cPanel or DIYtheme.  I chose DIYtheme route because it is faster to make rapid, on-the-fly changes.

Step 1: Log into WordPress

Step 2: Click on the Thesis link to expand the drop down list

Step 3: Click on the Custom File Editor

Step 4:  Select custom_functions.php from the drop down menu and click edit




Recovering from a custom_functions.php error

There are two possiblescenarios:

Scenario 1:  File is corrupted but you can still access the WordPress-DIYtheme application
Scenario 2:  File is corrupted and you CANNOT access the website,Wordpres or DIYtheme application

For scenario 1, fixing it is quite easy.  Just open custom_functions.php version prior to the broken one in notepad, copy and paste via DIYtheme’s Custom File Editor.

For scenario 2, involving a fatal error where you are unable to access the front end (website/WordPress/DIYtheme), you need to log in using your cPanel credential and either copy & paste using cPanel’s editor, or just upload the custom_functions.php text file version that is working.

Thanks for reading!

Leave a Reply