

Please note that WPCode has other options where you could run code snippets, for example run it only for logged-in users, specific pages, or for users who have selected role.

If you want to use one of the filter hooks that run on the back-end only, for example, mepr-admin-subscriptions-cols, you can use “Admin Only” option from Location. In VS Code: Menu -> Code -> Preferences -> User Snippets. I could also use “Run Everywhere” option, so my code would run on the entire site including WordPress Dashboard, so the back-end. It means that code snippet will run on front-end only so on all pages where regular users have access including Account page. In the example above I used mepr-account-nav-home-label filter hook to change Home label on Account page on front-end so I used “Frontend Only” as Location. All you need to do is to check/uncheck checkboxes under Status column in Code Snippets table. Your code snippet should work.Įnabling and disabling code snippets is easy. Hit “Save Snippet” button to save code snippet.Check “Inactive” checkbox field so it will be “Active”.Make sure that “Auto Insert” option is selected. Snippetis a programming term for a small region of re-usable source code, machine code, or text.Add your code snippet to “Code Preview” field.Change Code Type to PHP Snippet so your code syntax will be checked for possible errors. A snippet is a small chunk of PHP code that you can use to extend the functionality of a WordPress-powered website essentially a mini-plugin with less load on your site.You will see a new Add Snippet window and all you need to do is hover over “Add Your Custom Code (New Snippet)” section and click “Use Snippet” button.

To add code snippets you need to click “Add New” button at the top of the Code Snippets section.
#CODE SNIPPIT INSTALL#
Once you install and activate WPCode plugin in Plugins section, you’ll notice Code Snippets section in WordPress Dashboard.
#CODE SNIPPIT HOW TO#
We’ll show you how to use one of the code snippets plugins, called WPCode - Insert Headers and Footers + Custom Code Snippets with MemberPress. Using custom code plugin might be a better option because you have more control over your snippets, activate them if you need, avoid possible errors, or use them on the back-end, front-end, or only on particular pages. If you want to add custom code, for example, use one of our action or filter hooks, you can either add the code at the end of your theme’s functions.php file, or use one of the code snippets plugins. How to add custom code snippets in WPCode
