There are code snippets available in GitHub repository that are frequently requested by WP Ultimo users who wish to add small functionalities like adding Google Analytics script on sign up pages or hiding meta box from admin dashboard.
This article will show you how to use or more specifically where to place these codes.
You can find the snippets on the link below.
There are 2 ways for you to add the code
- On your theme's functions.php file.
- Must-Use Plugins (mu-plugins)
How to add the snippet on your theme's functions.php file.
- Log into your WordPress Network admin dashboard and go to Themes >Theme Editor (See screenshot below).
- On the "Edit Themes" page, make sure that you have your active theme selected on the dropdown field located on the upper right hand side of your screen (#3 on screenshot below).
- Click the functions.php file under the "Theme Files" sections to load the file.
Scroll down at the bottom and paste the WP Ultimo snippet you got from GitHub repository.
How to create Must-Use Plugins (mu-plugins)
WordPress has a feature that allows you to load custom functionality called "Must-Use Plugins", or "mu-plugins" for short.
These special mu-plugins are loaded before all other regular plugins, and they can’t be deactivated. In a multisite network, the code in these mu-plugins will be loaded on all the sites in your installation.
1. Use FTP or SSH to access the filesystem of your WordPress install.
2. Inside the wp-content directory of your WordPress install, create a new directory named: mu-plugins.
3. Create a new php file on your computer named wu-snippet.php using notepad or any code editor.
4. Place the WP Ultimo code snippet you got GitHub repository into the file and save it. You can also add this code on top of the code snippet to label your mu plugin.
* Plugin Name: WP Ultimo Snippet
* Description: Adds custom function
* Author: wu support
5. Upload the wu-snippet.php to your web server inside the newly-created wp-content/mu-plugins directory.
6. The MU Plugin should look like this on your plugin page.