How to Add Settings Link to Plugin Page in WordPress

Hello developer, hope you are doing well. In this tutorial i am going to discuss about how to create WordPress add settings link to plugin page. If you are a plugin developer then you will know that sometimes we need to create plugin settings page.

From plugin settings page a user can change plugin options and use that plugin as they want. So in this tutorial we will make a simple WordPress plugin to show you how to create a custom WordPress plugin settings page.

If you are going to create your own WordPress plugin and you don't know how to add a plugin settings page in your plugin, then this tutorial is for you. We don't need WordPress plugin settings page generator, we will create it with just simple bit line of code.

Preview:

wordpress-add-settings-link-to-plugin-page

 

Now let's start. Just paste this below code to your plugin page and see this settings page will be added.


/**
 * 
Plugin Name: CodeChief
Plugin URI: https://wordpress.org/plugins/coodechief
Description: A simple test plugin for settings page
Version: 1.0.0
Author: Mahedi Hasan
Author URI: https://wordpress.org/authors/coodechief
License: GPLv2 or later
Text Domain: codechief
*/


//Plugin Settings Page
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'codechief_settings_page');

function codechief_settings_page($links)
{
    $links[] = '' . esc_html('Settings', 'codechief') . '';

    return $links;
}

 

If you need your plugin menu also, then you can add this hook in your plugins file. Then you will get your plugin menu in admin panel.

//Customize your plugin page from here
function codechief_custom_plugin_page()
{
    add_options_page('Page Title', 'CodeChief', 'manage_options', 'codechief', 'options_page');
}
add_action('admin_menu', 'codechief_custom_plugin_page');

function options_page()
{
    echo "Hello devs";
}

Then you will see it in your settings options like below.

wordpress-plugin-settings-page

 

Check also : How to Create an Advanced Theme Options Page in WordPress

 

Hope it can help you.

 

A web enthusiastic, self-motivated Full-Stack Web Developer from Dhaka, Bangladesh with experience in developing applications using JavaScript, Laravel & Wordpress specifically. Facebook Github Website