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

Run Code Snippets on Demand

Starting with version 2.1.12 of WPCode you can execute PHP snippets on demand.

This is especially useful when you want to run pieces of code that you need to be sure are only executed once or that you need to control when they are executed.

In order to run snippets on demand, you need to follow a few simple steps:

1. Choose the PHP Code Type for your snippet, in order to do that please click the Code Type dropdown as shown below and select PHP Snippet.

Change code type

2. Choose the “On Demand” location in the Insertion settings:

First, click the Location picker:

And from the menu select “On Demand” under the “PHP Snippets Only” locations list:

Choose the On Demand location

3. Finally, with that selected you will see that the status toggle next to the Save button has been replaced with a button “Execut Snippet Now”. Clicking this button will save the snippet with its code and settings and immediately execute the snippet. If you wish to save the snippet without executing it you can always use the “Save Snippet” or “Update” button as usual.

Execute snippet now button

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.