Customized WordPress: Applying Patches to WordPress

We’ve talked a lot already about basic subversion, creating a WordPress repository and bundling externals such as plugins. This will accomplish most of what you probably want or need to do with a Custom WordPress repository. However, there may be modifications that you’d like to integrate into the core – perhaps patches that you’ve worked up personally or patches that have been submitted to WordPress that perhaps never saw the light of day. Never fear, you can apply patches to your repository to customize the code for future use.

For this example, let’s use the patch in ticket #2177 submitted to WordPress Trac as an example. This patch, or diff as they are called, has been added to the WordPress core for WordPress 2.3 and provides hooks for all the feeds and related data elements on the WordPress dashboard. This means that you will be able to replace the feeds used with your own.

Say you didn’t want to wait until WordPress 2.3 is released later this summer. You can easily take this diff and apply it to your own WordPress repository. Simply grab the diff from Trac (Hint:

macbrain:~/svn aaron$ wget -O mypatch.diff

) then use the



macbrain:~/svn aaron$ patch -d wpwc -p0 -N < mypatch.diff

This command means “apply mypatch.diff to the files designated in the diff starting in the wpwc directory”. You could actually place all these patches in a shell script and run them consecutively if there’s a bunch.

Finally, when you’ve patched your working copy, don’t forget to commit your changes!

macbrain:~/svn aaron$ svn commit wpwc -m "Applied #2177 to Repository"

Published by Aaron Brazell

Aaron Brazell is a Baltimore, MD-based WordPress developer, A Senior WordPress Developer for the NBA, a co-founder at WP Engine, WordPress core contributor and author. He wrote the book WordPress Bible and has been publishing on the web since 2000. You can follow him on Twitter, and on his professional blog.