How to integrate TGM Plugin Activation into a WordPress theme

If you are a theme developer and want to create a big theme with many features then you might need to include some plugin so that the user can install them after the theme activation. Specially if you are a premium theme developer, you need it.

You can easily install and integrate the TGM plugin into your custom theme. Lets learn it by 2 steps.


Step – 1:

Download the TGM plugin library and place it inside your theme folder. Here you can download the TGM .


TGM Plugin Khalilthemes
TGM Plugin Download page


Step – 2:

There you can customize and include the theme name and slug to match your theme. If the plugin address is like yourtheme/inc/tgm then you need to include the following line into functions.php .


include_once ( get_template_directory() . '/inc/example.php' );


The above line will catch the plugin files so it will now start working. Now you need to specify the plugin name and directory.


TGM plugin
TGM files


Step – 3:

Here, the plugins folder contains the plugins user can install after the theme activation. What we need to do is just change the example.php file and specify the plugins to be installed after theme activation. Open that file and find the line around 50 -60, you will get an array of plugins, it is actually the list of plugins that will appear after theme installation. There will see some default plugin setting options, you delete those example and insert the following lines to include contact form 7 plugin into your theme.


'name' => esc_html__('Contact Form 7', 'themetext'),
'slug' => 'contact-form-7',
'required' => false,


In the above code, you can change the 4th line required value false to true if you want that plugin installation is must to run the theme.

Slug is the url of the plugin that is located at site .

name is the plugin name that will appear in the WordPress admin dashboard.

The above is the example of using a plugin from WordPress repository. If you want to include the plugin from theme folder then you need to ad another line . Look at below codes:


'name' => esc_html__('Plugin Name', 'themetext'),
'slug' => 'plugin-name',
'source' => get_template_directory() . '/inc/tgm/plugins/',
'required' => true,


You can add as many item as you want like the above way. Let me know if you have any issue installing the tgm plugin.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top