ie8 fix
madison

DIY-IT

David Gewirtz

How to upgrade a WordPress theme after you’ve hacked the heck out of it

By | September 6, 2011, 2:39am PDT

Summary: Have you ever wanted to upgrade a heavily modified theme and seamlessly knit all your changes into the new code? Here’s how.

Another big project of mine is a major migration of a legacy CMS to WordPress. I’ll tell you all about it another time, but first, I wanted to get you excited about DIY-IT by giving you some hands-on how-to material you can put to work right away.

If you’ve ever worked with WordPress, you know one of its great appeals is the rich library of available themes. There’s a vibrant commercial theme marketplace, filled with many talented designers.

Since WordPress is written in PHP, nearly all of its themes are available in source code, which means they can be customized. There are a few theme makers who (I think wrong-headedly) try to compress and encrypt their themes, but these folks are in the minority.

In any case, while you may choose to use a theme as-is, out of the box, I tend to heavily hack anything I can get my hands on, and that’s certainly been the case with themes. The gotcha, of course, is I also like to take advantage of feature and security upgrades and that leads to an inevitable conflict: how do I use the new theme version, but knit all my changes seamlessly into the new code?

I’ve long used lab notes to keep track of my changes, but invariably I’ll have to do a late-night emergency fix and and there have been (a few) occasions where I didn’t get around to documenting it. So, I set out to find a solution driven by the code itself. I found one, it works exceptionally well, and (heh, I love this!) it’s free.

There are essentially three main steps:

  1. Compare the original theme distribution with your changes and annotate your code
  2. Compare your annotated code to the new theme and merge your changes in
  3. Test the theme and upgrade supporting files

As it turns out, this process works out exceptionally well. I upgraded three sites in less than half a day, and each had a ton of changes that needed to be incorporated. Here’s what I did.

Next: Find the changes (step 1) »

Topics

David Gewirtz, Distinguished Lecturer at CBS Interactive, is an author, U.S. policy advisor, and computer scientist. He is featured in The History Channel special The President's Book of Secrets.

Disclosure

David Gewirtz

At various times during his adult life, David has voted for both Democrats and Republicans, and has been disappointed by both. He is deeply disturbed by how partisanship has come before patriotism in America, which gives him the freedom to pick on both sides.

David is a frequent guest on TV and radio stations across America and can usually be heard or seen on-the-air at least once a week. He writes weekly commentary and analysis for CNN’s Anderson Cooper 360 and has been interviewed by Fox News, CNN, various ABC and NBC affiliates, and Canada’s Global TV. He has been a featured guest on National Public Radio and has also been featured on Voice of America, Radio Free Europe, and Radio Liberty where his commentaries on technology, industry, and emerging nations have been broadcast into 46 countries (all in their own unique translations).

David is the executive director of U.S. Strategic Perspective Institute, a nonprofit research and policy organization. He is the Cyberterrorism Advisor for the International Association for Counterterrorism & Security Professionals, a columnist for The Journal of Counterterrorism and Homeland Security and a special contributor to Frontline Security Magazine. He is a member of the FBI’s InfraGard program, the security partnership between the FBI and industry. David is also a member of the U.S. Naval Institute and the National Defense Industrial Association, the leading defense industry association promoting national security.

David is an advisory board member for the Technical Communications and Management Certificate program at the University of California, Berkeley extension. He is also a member of the instructional faculty at the University of California, Berkeley extension.

David’s “day job” is as publisher and editor-in-chief of ZATZ publishing, an online publisher of technical magazines. Other than than his ownership stake in Component Enterprises, Inc. (the parent company of ZATZ), David has no additional industry investments.

ZATZ has many advertisers who do, in part, provide for David’s lush income and extravagant lifestyle. Most of them are IBM and Lotus aftermarket suppliers, some of them make goodies for Microsoft Outlook, and a few make all sorts of strange mobile devices and add-on products. David has been a regular judge of the IBM Awards, but has no formal financial interest in or with IBM.

Because the ZATZ online magazines often review products, David and ZATZ are sent an overwhelming stream of unsolicited, silly, and often useless products to review. Because they’re such a pain to track and ship back, these products often wind up in a dumpster or fill up the corner of a large closet. Although David has no plans to review products in connection to his ZDNet blog, if he does do a product review, he will disclose any relationship completely in that posting.

Both through ZATZ and independently, David derives a small income through various advertising and sales relationships with Amazon.com and Google. These are minor relationships and they will not impede his willingness or ability to chastise either company should they deserve it.

David has many other business relationships, but none of them relate to anything he covers in his ZDNet blog. David does have a bit of the sales-guy bug and if he’s not doing a sales deal with someone at least once a month, he goes through withdrawal. He has a number of consulting clients, but none of them relate to anything he covers for ZDNet (and if they ever do, he will either disclose that fact, or decline to write about them).

Back in the 1980s, David held the unusual title of “Godfather” at Apple. He has written and published 40 incredibly simplistic applications for Apple’s iPhone.

Although David is forbidden to disclose the terms of his iPhone developer agreement, he isn’t drinking the Apple Kool Aid, will never be confused with a metrosexual, and feels free to mock Apple, and Apple users, any time the occasion permits, on alternate Tuesdays, or if he’s bored.

Biography

David Gewirtz

In addition to hosting the ZDNet Government and ZDNet DIY-IT blogs, CBS Interactive's Distinguished Lecturer David Gewirtz is an author, U.S. policy advisor, and computer scientist. He is featured in The History Channel special The President's Book of Secrets, is one of America's foremost cyber-security experts, and is a top expert on saving and creating jobs. He is also director of the U.S. Strategic Perspective Institute as well as the founder of ZATZ Publishing.

David is a member of FBI InfraGard, the Cyberwarfare Advisor for the International Association for Counterterrorism & Security Professionals, a columnist for The Journal of Counterterrorism and Homeland Security, and has been a regular CNN contributor, and a guest commentator for the Nieman Watchdog of the Nieman Foundation for Journalism at Harvard University. He is the author of Where Have All the Emails Gone?, the definitive study of email in the White House, as well as How To Save Jobs and The Flexible Enterprise, the classic book that served as a foundation for today's agile business movement.

10
Comments

Join the conversation!

Just In

dgpcnnu 98 woq
adfwekrwe1801-24378942231435320639506983028494 24th Nov
vytdyi,xzwjjgga39, fqret.
0 Votes
+ -
Why Re-Hack the WordPress Theme?
Edward.Caissie 6th Sep
I'm just wondering why you would continue to essentially recommend re-hacking the theme given it would be much easier and more future-proof to put all of the "hacks" into a Child-Theme. This leaves the Parent-Theme ready for any future updates and would most likely also eliminate the lost time put into re-hacking the theme.
@Edward.Caissie You make a very good point and Parent/Child themes are a very useful approach that I would recommend to most WordPress users.

I actually tried implementing the project site using a child theme and found that it would be a maintenance nightmare, because my implementation changes so many functions throughout the theme. I'd essentially be moving most of the files down to the child folder and I'd still have this comparison challenge when the theme upgraded.

That said, for most users, the child theme approach is definitely the way to go. Here's a link for anyone who wants to explore this:

http://codex.wordpress.org/Child_Themes
0 Votes
+ -
Child themes.
dave@... 6th Sep
Four suggestions:

1. Make sure you always keep the WordPress core updated.
2. Use http://wordpress.org/extend/themes/twentyeleven.
3. Stay away from frameworks unless you're a themer.
4. Always create or use a child-theme, never the original: http://codex.wordpress.org/Child_Themes.
0 Votes
+ -
What he said - use child theme (nt)
bmeacham98@... 6th Sep
nt
0 Votes
+ -
Really?!? A diff?
daengbo 6th Sep
Using a diff to create a patch set and applying the patch set to the upgraded code. Wow. Insightful. O_o
Nice post man, thanks for sharing.
Fantastic!!! Its a differ to create a patch set and applying the patch set to the upgraded code... http://www.apptha.com/category/extension/Wordpress/Apptha-Banner
metin2 pvp serverler W mt2 W metin2 W metin2 hile . yemek tarifleri T guzel sozler U sex hikayeleri Z metin2 indir T metin2 pvp serverlar A metin2 turk N mt2 pvp E face M sex . mynet C Twitter OM..............
0 Votes
+ -
pslgmzx 02 iwe
bdfwekrdfe3701-24379006336416627462375061784412 22nd Nov
idxbps,uricigdg49, jshgh.
0 Votes
+ -
dgpcnnu 98 woq
adfwekrwe1801-24378942231435320639506983028494 24th Nov
vytdyi,xzwjjgga39, fqret.

Join the conversation!

Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]
ie8 fix
Click Here
ie8 fix

The best of ZDNet, delivered

ZDNet Newsletters

Get the best of ZDNet delivered straight to your inbox

Facebook Activity

White Papers, Webcasts, & Resources
ie8 fix
ie8 fix