WPCode Logo

WPCode Documentation

Documentation, Reference Materials, and Tutorials for WPCode

Most Popular

Get free tips and resources right in your inbox, along with 500+ others

Follow Us

Using Code Revisions

Would you like to undo a change to a code snippet, or see exactly what changed since it last worked?

In this guide, we’ll show you how to compare a snippet’s revisions, restore an earlier version, and choose how many revisions WPCode keeps.

Requirements: Code Revisions is available in the paid versions of WPCode.

Before you get started, make sure WPCode is installed and activated on your WordPress site.

Checking a Snippet’s Revision History

To get started, we’ll find the list of saved versions for one of your snippets.

Each time you save a change to a snippet, WPCode keeps a copy of it as a revision. That copy includes the code and the snippet’s settings.

From your WordPress admin sidebar, go to Code Snippets » Code Snippets. In the list, click the title of the snippet you want to check.

The WPCode Code Snippets list opened from the Code Snippets menu in the WordPress admin sidebar, with an arrow pointing at the Fall Sale Banner snippet title

Near the bottom of the snippet editor, the Code Revisions box lists every saved version, newest first. The top entry is marked Current Version. Beside an older entry, click Compare to open the revisions page with that version selected.

The Code Revisions box in the snippet editor listing five saved versions, with an arrow pointing at the Compare link beside the oldest one

Next, we’ll look at what the revisions page shows you about each version.

Reviewing What a Restore Will Change

The revisions page compares each revision with your live snippet. Nothing changes on your site while you look around here.

On the left, the Revisions list shows when each version was saved and who saved it. A badge on each row tells you how far that version is from what’s live:

  • Current marks the version that’s live on your site now.
  • 1 change, 3 changes, and so on count the settings that change if you restore that version. All of the code counts as one change.
  • Same as current means that version matches your live snippet. Restoring it changes nothing.

To see the details for a version, click it in the list.

The Revisions list with the newest version marked Current and older versions marked 1 change, 1 change, 3 changes, and 5 changes, with an arrow pointing at 5 changes on the oldest one

On the right, a table headed Current → After restore lists only the settings that change if you restore. Your live value comes first, crossed out. The restored value follows the arrow.

The Current to After restore table, showing the title changing from Fall Sale Banner to Sale Banner and a code comparison with removed lines in red and added lines in green

In the Code row, removed lines are red and added lines are green. The words that changed within a line are highlighted. Unchanged code is folded away, apart from two lines around each change. That keeps the edits easy to spot.

When the code has more than one change, the counter shows where you are, such as Change 1 of 3. To jump to the following change, click Next. To read the whole file instead, click Show All Lines.

The code comparison toolbar reading Change 1 of 3, with an arrow pointing at the Next button and Show All Lines on the right

Further down, the table lists any other settings that change, such as the priority, device type, or note. These rows are worth checking before you restore. An older version can bring back settings you’ve since changed on purpose, not just old code.

Table rows showing Priority changing from 5 to 10, Device Type from Any device type to Desktop only, and Note from Runs until October 31 to Empty

Once you’ve checked every row in the table, you’re ready to restore that version.

Restoring a Revision

When you’ve found the version you want, click Restore This Revision at the top right of its details.

The details of a revision from Oct 3, with an arrow pointing at the Restore This Revision button

An overlay names the settings the restore will change. It also asks how you’d like to restore the revision:

  • Restore now replaces your live snippet straight away. If the snippet is active, it stays active. Choose this when you’re sure the older version is the one you want.
  • Load into the editor first opens the older version in the snippet editor without saving anything. Choose this when you want to check it or adjust a line before it goes live.

With Restore now selected, click Restore Revision.

The Restore Revision overlay listing Title, Code, Priority, Device Type and Note as the changes, with Restore now selected and an arrow pointing at the Restore Revision button

WPCode saves the restored version as your new current revision and keeps you on the revisions page. The row you restored from is now marked Restored.

The version you replaced stays in the list. You can restore it again if you change your mind.

The Revisions list after a restore, with a new Just now version marked Current and the Oct 3 version marked Restored

If you’d rather check an older version before it goes live, load it into the editor instead.

Loading a Revision into the Editor First

To try an older version before saving it, open the same overlay and select Load into the editor first. The button changes to Open in Editor. When you’re ready to continue, click it.

The Restore Revision overlay with Load into the editor first selected and an arrow pointing at the Open in Editor button

The snippet editor opens with the older version filled in. A notice reminds you that nothing is saved yet. Your live snippet stays as it was until you save.

Make any edits you need. When the snippet looks right, click Update to save it.

The snippet editor showing the notice Revision loaded into the editor, nothing is saved until you click Update, with an arrow pointing at the Update button

If you leave the editor without clicking Update, nothing changes on your site.

WPCode keeps revisions of your global header and footer code too.

From your WordPress admin sidebar, go to Code Snippets » Header & Footer.

The Global Header and Footer page opened from the Code Snippets menu in the WordPress admin sidebar, with Header and Footer highlighted

Below the Footer box, the Code Revisions box lists each saved version. Its Compare links open the same revisions page you used for snippets.

The Code Revisions box on the Global Header and Footer page listing five saved versions with Compare links

Restoring works the same way as for snippets, with one difference. For header and footer code, the Restore Revision button in the overlay replaces your live code straight away.

Limiting How Many Revisions WPCode Keeps

WPCode keeps every revision unless you set a limit. That way, you can always go back to any version you’ve saved. A limit is useful on sites where snippets change often and the list grows long.

From your WordPress admin sidebar, go to Code Snippets » Settings. The General Settings tab opens by default.

The WPCode General Settings tab opened from the Code Snippets menu in the WordPress admin sidebar, with Settings highlighted

Further down the tab, turn on the Remove Revisions toggle. A Revisions to Keep field appears below it.

The Remove Revisions toggle switched on, with an arrow pointing at it, and the Revisions to Keep field below set to 30

Revisions to Keep sets how many revisions WPCode keeps for each snippet, each page with page scripts, and your header and footer code.

It starts at 30. The lowest number it accepts is five. If you’re not sure what to choose, keep the starting value.

The limit counts revisions, not their age. An old revision stays as long as it’s within the number you set.

WPCode removes revisions past the limit the next time a change to that item is saved. Removed revisions are gone for good. Choose a number that leaves you enough history to go back to.

When you’ve set the number, click Save Changes at the bottom of the tab.

The Revisions to Keep field set to 30 above the Save Changes button, with an arrow pointing at Save Changes

That’s it! You now know how to compare snippet revisions, restore an earlier version, and keep the revisions list to a size that suits your site. Next, take a look at our guide on using Testing Mode. It lets you try snippet changes privately before your visitors see them.

Frequently Asked Questions

Below, we’ve answered some of the most common questions about code revisions in WPCode.

Does WPCode create a revision every time I save?

Only saves that change something do. WPCode compares the snippet’s code and settings with the previous version. If nothing changed, no new revision is added.

Can I undo a restore?

Yes. The version you replaced stays in the revisions list. You can restore it the same way. If you’ve turned on the revision limit, newer saves can eventually push it out of the list.

Does restoring a revision change whether my snippet is active?

No. When you use Restore now on an active snippet, it stays active.

Do scripts I add to individual pages have revisions?

Yes. Page scripts keep revisions on the Revisions tab of the WPCode Page Scripts box, on that post or page’s edit screen. Like header and footer revisions, they restore straight away.

Will the revision limit remove my old revisions on a schedule?

No. WPCode removes revisions past the limit the next time a change to that item is saved. Removal happens as part of that save, rather than at a set time.

Still stuck? How can we help?

Last Updated on

Get Started Today & Add Your Own Snippets

Future-proof your website with WPCode Snippets and improve the way you manage code across all your websites.