How to Add a Recommended Plugin to a Theme

This post will explain how to add a recommended plugin to your theme using the TGM Plugin Activation tool. This is simple and relatively straightforward, and will allow Ultimate FAQ theme developer affiliate program members to add Ultimate FAQ as a recommended plugin when their theme is activated on someone’s site.

 

Step 1: 

Visit the custom TGMPA generator page.

Step 2:

  • Select the “Theme” radio button.
  • In the “Text Domain” field type in your theme’s text domain (which is usually the same as its slug).
    More info about text domains in WordPress can be found here
  • In the “Function Prefix” field, type in the prefix you want to use for the functions TGM will create. If you are already using prefixes for your theme’s functions (which is a great idea to make sure you avoid conflicts that occur from having the same function names as other plugins, etc.), we recommend using this same prefix here.
  • Put your theme name in the “Name” field.
  • Click the “Generate” button. It will download the files you need to set this up.

Note: You’ll only need two files from the .zip that was downloaded, “class-tgm-plugin-activation.php” and “example.php”.


Step 3:

  • First, you’ll need to add the “class-tgm-plugin-activation.php” file to your theme folder. You can either add it to the main theme folder or in a sub-directory. We recommend in a sub-directory. For the purpose of this post, let’s assume you’ve added it to a sub-directory called “inc”.
  • Next, open up the “example.php” file in your text/code editing program. Because of the steps you followed in “Step 2”, this file will already contain the correct text domain, the correct theme info and all the correct function prefixes. There are two things you’ll need to do in this file:
    1. Look for the following line of code:require_once get_template_directory() . '/path/to/class-tgm-plugin-activation.php';Replace this with the path to your file. In our example, we’ve placed the file in a sub-directory called “inc”. So, in that case, you’d want to change that line of code to:require_once get_template_directory() . '/inc/class-tgm-plugin-activation.php';
    2. Look for the section of code that starts with “$plugins = array(” and do the following:
      • There are five arrays in this section. You can delete them all except the fourth one, which will look like:
        array(
            'name' => 'BuddyPress',
            'slug' => 'buddypress',
            'required' => false,
        ),
      • You want to use this array to replace the information there with the information about our plugin. So, you should change the above array to:
        array(
            'name' => 'Ultimate FAQ',
            'slug' => 'ultimate-faqs',
            'required' => false,
        ),
      • After, your “$plugins = array(” section should look like:
        $plugins = array(
            array(
                'name' => 'Ultimate FAQ',
                'slug' => 'ultimate-faqs',
                'required' => false,
            ),
        );

Step 4:

After completing this, you’ll want to copy all of the code in the “example.php” file and paste it in your theme’s “functions.php” file.

Step 5:

Upload the revised version of your theme, with the new file in the “inc” folder and the new code in the “functions.php” file, to a test install. Make sure you deactivate the theme if it is currently the active theme. Also, make sure the Ultimate FAQ plugin is not installed. Then activate the theme. You should see the box pop up at the top indicating that this theme recommends the “Ultimate FAQ” plugin.


Install Ultimate FAQ – WordPress Plugin

30,000+ Installations

 


You are now all set. Whenever your theme is activated, it will recommend the Ultimate FAQ plugin.

 

Call to action box goes here
Looking to Make Some Extra Income?
Become an Affiliate
Need a Plugin to Improve Your Site?
Browse Plugins Now
How Bad Internet Gave Birth to Cyber Monday Deals: The Origins of E-Comm’s Biggest Day
How Bad Internet Gave Birth to Cyber Monday Deals: The Origins of E-Comm’s Biggest Day

The Birth of Cyber Monday Deals No lines, crowds or crazy dads fighting over a kid’s car – what’s not to love about Cyber Monday? Unlike the madness that is on-foot retail shopping on Black Friday, the origins of “Cyber Monday” have a decidedly practical vibe. It was the early 2000’s. There were only about…

4 Great WordPress Plugins that Have Affiliate Programs You Can Join Today (And so useful, you’ll want to use them too)
4 Great WordPress Plugins that Have Affiliate Programs You Can Join Today (And so useful, you’ll want to use them too)

The world of WordPress is a great place to try your hand at affiliate marketing. Most people who use WordPress, especially those creating or updating websites, are constantly searching for tools to enhance or improve their site.  With over 55 thousand plugins in the WordPress directory, it’s no wonder users are looking for plugin recommendations…

Get Busy Upgrading: WordPress Black Friday and Cyber Monday Deals 2018
Get Busy Upgrading: WordPress Black Friday and Cyber Monday Deals 2018

Black Friday to Cyber Monday has become a great time of year for users of WordPress. When else can you easily find great deals across the board on hundreds of plugins, themes and hosting? In the spirit of the season, here’s our own list of our most popular and useful plugins that could give your…

Discover More Posts
Browse Plugins Now