How to Add a Link to Your Plugin Settings Page in The WordPress Plugin List

Published in WordPress.

Watch our video

There is a better version of your web

Share this post

Today I’ll show you a little trick that will surely be useful if you are a WordPress plugin developer.

When you develop a plugin for WordPress, it is common to create a new menu for the plugin and its internal pages –including a settings page– in the WordPress Dashboard.

However, many times we download plugins from the official WordPress plugin directory and we find that once we install and activate a plugin, we don’t know what else we have to do with it in order to make it work.

In the list of plugins that we have in the WordPress Dashboard we can see the plugins that we have installed and active. In addition, below the title of each plugin there are additional actions to activate, deactivate or eliminate the plugin itself.

List of plugins inside the WordPress desktop.
List of plugins inside the WordPress dashboard.

Let’s see how to add more actions to our plugins to make it easier for users who download and activate a plugin to, for example, visit its settings page. To this purpose we are going to add an additional link to the plugin settings page.

What we’re going to need is to use the plugin_action_links_{$plugin_file} filter in WordPress. You can find its documentation here.

Basically, this filter has as parameter a list with the links that are just below the name of the plugin. We just have to create an additional link and add it to this list in the filter, so that WordPress ends up showing it in the user interface.

The code below adds a link to the settings page in our plugin Nelio Content plugin:

As you can see, the name of the filter is plugin_action_links_{$plugin_file} but we in the code have used plugin_action_links_nelio-content/nelio-content.php. This is because the {$plugin_file} part refers to the path of the main plugin file within the WordPress plugins directory.

Our plugin Nelio Content has nelio-content.php as the main file, which is located inside the nelio-content folder. Hence, we have used the string plugin_action_links_nelio-content/nelio-content.php in the filter name.

Remember to adapt this to your specific case. You can also use WordPress functions like plugin_basename to build this name, which you will find explained here.

Apart from that, the code is quite simple. We create a link ($settings_link) and add it to the list ($links) just before returning it.

The settings page of our plugin is at the URL /wp-admin/admin.php?page=nelio-content-settings. In line 6 of the code we assemble this URL using the function get_admin_url() (more info here) to which we concatenated admin.php at the end. With this we get /wp-admin/admin.php. To add the page parameter that ends up mounting the URL correctly we use the function add_query_arg that you can find here.

With the previous code we get the link to the settings page of the plugin as you can see in the following image:

View of the list of plugins with the additional link added in our plugin.
View of the list of plugins with the additional link added in our plugin.

With what we’ve explained here you have the possibility to add the links you want in the list of plugins on the WordPress dashboard. However, use this wisely. Do not fill the list of actions with links unless they provide some value to the user. Otherwise you will be worsening your user experience.

Featured image by Rima Kruciene on Unsplash.

6 thoughts on “How to Add a Link to Your Plugin Settings Page in The WordPress Plugin List

  1. Thank you, Antonio! Your codes helped me.

    May I know what modifications to the codes will I need to do if I need the ‘Settings’ link to be in front instead of at the back?

    Appreciate if you can enlighten me, thank you!

  2. The code example doesn’t show on your page anymore!

  3. how to change the position or arrangement of the menu item.

    For example, on my side it appeared like:

    Deactivate | Settings

    but for other plugins, it’s as shown below

    Settings | Deactivate

    probably “Settings | Deactivate”, comes with a better user experience(UX). Please let me know if there is away to make the arrangement of my links like the other plugins

    thanks

Leave a Reply

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

I have read and agree to the Nelio Software Privacy Policy

Your personal data will be located on SiteGround and will be treated by Nelio Software with the sole purpose of publishing this comment here. The legitimation is carried out through your express consent. Contact us to access, rectify, limit, or delete your data.