• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Adding a link to the settings of a WordPress plugin

Learn in this tutorial how to add a link to a plugin’s settings in the plugin management page.

I don’t know if it happens to you too, but with some plugins I never remember where I have to go to modify their settings (own panel, inside general settings…)

That’s why I often go to the plugin management page and look for the “Settings” link.

Settings option on the WordPress plugin page
Settings option on the WordPress plugin page.

This is why I think that if you are going to create a plugin that has a settings page it is a good idea to include this option.

So in this tutorial you are going to see how to do it.

Snippet to add a link to the plugin settings in WordPress

Add the following snippet to the main file (or the one of your choice) of the plugin:

To see this and another 839 code snippets of this website, login or subscribe here.

As you can see, in this case you use a namespace to avoid collisions with function names. That is why we define it at the beginning.

To add the link you use the plugin_action_links_{$plugin_file} filter. In this case the name is plugin_action_links_osom-login-page-customizer/osom-login-customizer.php where:

  • osom-login-page-customizer > is the name of the plugin folder
  • osom-login-customizer.php > is the name of the plugin’s main file

Next you define which URL the settings link will direct to. In this case, the plugin has defined the osom_lc_main_menu page. That is, the link will go to the path /wp-admin/admin.php?page=osom_lc_main_menu.

This is the part that you must replace with the page where you have defined the settings of your plugin.

Conclusions

Now you know how to add a link to the settings of a plugin in WordPress.

Any questions? I read you in the comments.

And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉

PHP Plugins

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?