{"id":68224,"date":"2021-03-15T09:00:00","date_gmt":"2021-03-15T13:00:00","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/?p=68224"},"modified":"2023-10-30T11:41:32","modified_gmt":"2023-10-30T15:41:32","slug":"create-a-wordpress-plugin","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/","title":{"rendered":"Create a WordPress Plugin: A Tutorial"},"content":{"rendered":"<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-1024x538.png\" alt=\"WordPress Plugin Creation Tutorial to help you Create a WordPress Plugin\" class=\"wp-image-69581\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-1024x538.png 1024w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-300x158.png 300w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-768x403.png 768w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1.png 1200w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/figure>\n\n\n\n<p>In this guide we\u2019ll walk you through creating your very first WordPress plugin. This will just be a simple plugin that adds some extra info to all of your posts. Using these same steps you can design and implement your own WordPress plugins! Remember, this is just an instructional plugin meant to show you the basics: try this out on a <a aria-label=\"staging site (opens in a new tab)\" href=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/softaculous\/softaculous-staging-tool\/\" rel=\"noreferrer noopener\">staging site<\/a> or a practice installation of WordPress. Do not install this on a live, important site crucial to your business; it\u2019s just for fun!<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#overview\">Create a WordPress Plugin<\/a><\/li>\n\n\n\n<li><a href=\"#script\">Create a WordPress Plugin Script<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#create-directory\">Create WordPress Plugin Directory<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/create-script\">Create WordPress Plugin PHP Script<\/a><\/li>\n\n\n\n<li><a href=\"#dashboard-access\">Accessing WordPress Plugin Script via WordPress Dashboard<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#create-function\">Creating a WordPress Function for a Plugin<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#unique-name\">Check to Ensure Function Name is Unique<\/a><\/li>\n\n\n\n<li><a href=\"#main-function\">Create Our Plugin\u2019s Main Function<\/a><\/li>\n\n\n\n<li><a href=\"#add-filter\">Use add_filter to Make WordPress Display Update<\/a><\/li>\n\n\n\n<li><a href=\"#full\">Full WordPress Function Results<\/a><\/li>\n\n\n\n<li><a href=\"#results\">Plugin Results when Activated<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#create-admin\">Create an Admin Menu in the WordPress Dashboard<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#blank-page\">Blank Plugin Page Accessed from Dashboard Menu<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#add-page\">Add WordPress Plugin Page<\/a><\/li>\n\n\n\n<li><a href=\"#wp-form\">Save WordPress Plugin Settings with a Form<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#break-down\">Code Break-Down<\/a><\/li>\n\n\n\n<li><a href=\"#non-functional\">Plugin Page with Non-Functional Form<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#register-plugin\">Register Plugin Settings with WordPress<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#add-action\">Add add_action Hook to Register Settings<\/a><\/li>\n\n\n\n<li><a href=\"#register-settings\">Register Settings with register_setting Function<\/a><\/li>\n\n\n\n<li><a href=\"#save-settings\">Plugin Settings are now Saved to the WordPress Database<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#read-settings\">Read WordPress Plugin Settings from Database<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#change-static\">Change Static Settings to be Database Driven<\/a><\/li>\n\n\n\n<li><a href=\"#get-option\">Use WordPress get_option Function to Pull Info from Database<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#completed\">Completed Extra Post Info WordPress Plugin<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"overview\">Create a WordPress Plugin<\/h2>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/wordpress-function\/first-extra-info-text-added-to-post.png\" alt=\"How to Create a WordPress Plugin extra info plugin on a WordPress site. \" style=\"width:516px;height:309px\"><\/figure>\n\n\n\n<p>Before you begin creating a WordPress plugin, you need to figure out the purpose of your plugin, and a unique name to give your plugin. This is important if you want to release your plugin to the <a rel=\"noopener noreferrer\" href=\"https:\/\/wordpress.org\/plugins\/\" target=\"_blank\">WordPress Plugin directory<\/a>.<\/p>\n\n\n\n<p>In this guide we\u2019re going to create a plugin called <span style=\"color: red;\">WordPress Extra Post Info<\/span>. This plugin will let users enter in extra information for WordPress posts.<\/p>\n\n\n\n<p>Here\u2019s a breakdown of our plugin creation workflow so you know what to expect: <\/p>\n\n\n\n<ol class=\"article_list wp-block-list\">\n<li><strong>Create a Plugin Script:<\/strong> First we need to create a PHP script and place it in the proper location for WordPress to recognize it as a proper WordPress plugin.<\/li>\n\n\n\n<li><strong>Create a WordPress Plugin Function:<\/strong> With your WordPress plugin script started, the next step will be to create the WordPress plugin function that actually contains the logic of what your plugin will do.<\/li>\n\n\n\n<li><strong>Create a WordPress Admin Menu for Your Plugin:<\/strong> Once the basics for your WordPress plugin are laid out, you\u2019ll want to create a WordPress admin menu so users can alter your plugin settings easily.<\/li>\n\n\n\n<li><strong>Create the WordPress Plugin Page:<\/strong> Once your admin menu is made, the next thing you\u2019ll want to do is create a WordPress plugin page.<\/li>\n\n\n\n<li><strong>Save WordPress Plugin Settings with a Form:<\/strong> Now that you have a very basic WordPress plugin page created, the next step is to save WordPress plugin settings with a form so that your plugin can load those settings later.<\/li>\n\n\n\n<li><strong>Register WordPress Plugin Settings to the Database:<\/strong> Now you can register WordPress plugin settings to the database, so a user\u2019s settings are kept for later use.<\/li>\n\n\n\n<li><strong>Read WordPress Plugin Settings from the Database:<\/strong> Finally, bring your plugin development full circle.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"script\">Create a WordPress Plugin Script<\/h2>\n\n\n\n<p>Our first step is to create a WordPress plugin script with some PHP code for WordPress to read. We\u2019ll upload the script to your WordPress <span style=\"color: red;\">\/wp-content\/plugins\/extra-post-info<\/span> directory. Use <a href=\"https:\/\/www.inmotionhosting.com\/support\/website\/ftp\/getting-started-guide\/\" aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\">FTP<\/a> or the <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/cpanel\/using-file-manager-in-cpanel\/\" aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\">cPanel File Manager<\/a> in order to upload or create your WordPress plugin PHP script.<\/p>\n\n\n\n<p class=\"alert alert-info\">Platform i users can use the <a href=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/wordpress-hosting\/central\/maintenance\/database-file-manager\/\">File Manager<\/a> tool.<\/p>\n\n\n\n<p>If you installed WordPress in your document root, WordPress plugins would go here:<\/p>\n\n\n\n<p class=\"cli\">\/home\/userna5\/public_html\/wp-content\/plugins<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"create-directory\">Create WordPress Plugin Directory<\/h3>\n\n\n\n<p>You\u2019ll want to create a new folder for your plugin first. This folder can simply be named the same as your plugin name. In my case I\u2019ve created a folder called <span style=\"color: red;\">\/extra-post-info<\/span>, so my full path to my plugin is now:<\/p>\n\n\n\n<p class=\"cli\">\/home\/userna5\/public_html\/wp-content\/plugins\/<span style=\"color: red;\">extra-post-info<\/span><\/p>\n\n\n\n<p>Now that you\u2019ve created a folder for your WordPress plugin PHP script to go into, you want to create the PHP script that will control your WordPress plugin, and place it in the folder you created.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"create-script\">Create WordPress Plugin PHP Script<\/h3>\n\n\n\n<p>I\u2019ve simply uploaded a PHP file to my newly created plugin directory, and called it <span style=\"color: red;\">extra-post-info.php<\/span><\/p>\n\n\n\n<p class=\"cli\">\/home\/userna5\/public_html\/wp-content\/plugins\/extra-post-info\/<span style=\"color: red;\">extra-post-info.php<\/span><\/p>\n\n\n\n<p>In the <span style=\"color: red;\">extra-post-info.php<\/span> script, I\u2019ve placed the WordPress plugin File Header info for the plugin I\u2019ll be creating:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">&lt;?php \/* <span style=\"color: red;\">Plugin name<\/span>: WordPress Extra Post Info <span style=\"color: red;\">Plugin URI<\/span>: https:\/\/example.com\/wordpress-extra-post-info <span style=\"color: red;\">Description<\/span>: A simple plugin to add extra info to posts. <span style=\"color: red;\">Author<\/span>: Jacob Nicholson <span style=\"color: red;\">Author URI<\/span>: https:\/\/InMotionHosting.com <span style=\"color: red;\">Version:<\/span> 0.5 *\/  ?&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"dashboard-access\">Accessing WordPress Plugin Script via WordPress Dashboard<\/h3>\n\n\n\n<p>Now you have a PHP script with WordPress File Headers inside of your WordPress plugin directory. Next, <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/logging-into-wordpress-dashboard\/\" aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\">login to the WordPress dashboard<\/a> and click on <strong>Plugins<\/strong> to see your newly created plugin:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"\/support\/images\/stories\/wordpress-development\/plugins\/file_header\/wordpress-file-headers-in-dashboard-view.png\" rel=\"lightbox-0\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/file_header\/wordpress-file-headers-in-dashboard-view.png\" alt=\"WordPress file headers viewed in dashboard\"><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-function\">Creating a WordPress Function for a Plugin<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"unique-name\">Check to Ensure Function Name is Unique<\/h3>\n\n\n\n<p>You\u2019ll want to wrap your entire plugin function inside of a <span style=\"color: red;\">if( !function_exists )<\/span> statement. That way, we only run our plugin\u2019s function if a function of that same name hasn\u2019t already been created by another WordPress plugin:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">if( <span style=\"color: red;\">!function_exists<\/span>(\"<span style=\"color: red;\">extra_post_info<\/span>\") ) {  }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"main-function\">Create our Plugin\u2019s Main Function<\/h3>\n\n\n\n<p>Now that we know our plugin name is unique, we want to actually start with the logic for our plugin. Our plugin will simply add some extra info to a post, so we\u2019ll start off very simply by just manually defining what info we want added.<\/p>\n\n\n\n<p>We start by declaring <span style=\"color: red;\">function extra_post_info($content)<\/span> which creates the function called <span style=\"color: red;\">extra_post_info<\/span>. This function pulls in the default WordPress <span style=\"color: red;\">$content<\/span> variable, which as you might guess is the content of the post we want to add extra info too.<\/p>\n\n\n\n<p>Within the newly created function, we setup a variable called <span style=\"color: red;\">$extra_info<\/span> which simply stores the extra text we\u2019d like to add to our post, in this case <span style=\"color: red;\">EXTRA INFO<\/span>.<\/p>\n\n\n\n<p>Finally before closing our function, we run <span style=\"color: red;\">return $content . $extra_info<\/span> which returns the original content of the post to WordPress, but with our added text appended to the end:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">function <span style=\"color: red;\">extra_post_info<\/span>(<span style=\"color: red;\">$content<\/span>) {   <span style=\"color: red;\">$extra_info<\/span> = \"<span style=\"color: red;\">EXTRA INFO<\/span>\";   return <span style=\"color: red;\">$content<\/span> . <span style=\"color: red;\">$extra_info<\/span>; }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"add-filter\">Use add_filter to Make WordPress Display Update<\/h3>\n\n\n\n<p>Now in order for our newly created <span style=\"color: red;\">extra_post_info<\/span> function to actually update the content of a WordPress post, we need to use the WordPress <span style=\"color: red;\">add_filter(\u2018the_content\u2019, \u2018extra_post_info\u2019)<\/span> hook.<\/p>\n\n\n\n<p>This hook lets WordPress know we want to filter our content before displaying. The second argument of <span style=\"color: red;\">extra_post_info<\/span> sets the function we want to filter our content through.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\"><span style=\"color: red;\">add_filter<\/span>('<span style=\"color: red;\">the_content<\/span>', '<span style=\"color: red;\">extra_post_info<\/span>');<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"full\">Full WordPress Function Results<\/h3>\n\n\n\n<p>If you followed along above, the full WordPress plugin function so far should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">if( <span style=\"color: red;\">!function_exists<\/span>(\"<span style=\"color: red;\">extra_post_info<\/span>\") ) {    function <span style=\"color: red;\">extra_post_info<\/span>(<span style=\"color: red;\">$content<\/span>)   {     <span style=\"color: red;\">$extra_info<\/span> = \"<span style=\"color: red;\">EXTRA INFO<\/span>\";     return <span style=\"color: red;\">$content<\/span> . <span style=\"color: red;\">$extra_info<\/span>;   }  <span style=\"color: red;\">add_filter<\/span>('<span style=\"color: red;\">the_content<\/span>', '<span style=\"color: red;\">extra_post_info<\/span>');  }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"results\">Plugin Results when Activated<\/h3>\n\n\n\n<p>Now you can <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/logging-into-wordpress-dashboard\/\" aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\">login to WordPress<\/a>, click on <strong>Plugins<\/strong> then activate the plugin by clicking on <strong>Activate<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/wordpress-function\/activate-wordpress-plugin.png\" alt=\"Showing the option to activate the plugin. \"><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/wordpress-function\/post-with-extra-post-info-plugin-disabled.png\" alt=\"Before the plugin is activated\"><figcaption class=\"wp-element-caption\">Before the Plugin is Activated<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/wordpress-function\/first-extra-info-text-added-to-post.png\" alt=\"After the Plugin is Activated\"><figcaption class=\"wp-element-caption\">After the Plugin is Activated<\/figcaption><\/figure>\n\n\n\n<p>Now as you can see our plugin successfully added the text <span style=\"color: red;\">EXTRA INFO<\/span> into our WordPress post.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-admin\">Create an Admin Menu in the WordPress Dashboard<\/h2>\n\n\n\n<p>To allow users to customize your plugin to fit their needs, you can create a WordPress admin menu. This creates a icon in the WordPress dashboard that a user can click on to view plugin settings.<\/p>\n\n\n\n<p>You define things like the <span style=\"color: red;\">$page_title<\/span> to set how your plugin menu looks. You also define the <span style=\"color: red;\">$function<\/span> which WordPress should use to create your plugin page that contains your settings.<\/p>\n\n\n\n<p>Then you use the <span style=\"color: red;\">add_menu_page<\/span> hook to actually create the menu and make it show up in the WordPress dashboard.<\/p>\n\n\n\n<p>Use the WordPress function <span style=\"color: red;\">add_action<\/span> along with <span style=\"color: red;\">admin_menu<\/span> to let WordPress know we\u2019re building an admin menu. Then pass the function name of your menu <span style=\"color: red;\">extra_post_info_menu<\/span> that sets up your menu item.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\"><span style=\"color: red;\">add_action<\/span>( '<span style=\"color: red;\">admin_menu<\/span>', '<span style=\"color: red;\">extra_post_info_menu<\/span>' );  function <span style=\"color: red;\">extra_post_info_menu()<\/span>{    <span style=\"color: red;\">$page_title<\/span> = 'WordPress Extra Post Info';   <span style=\"color: red;\">$menu_title<\/span> = 'Extra Post Info';   <span style=\"color: red;\">$capability<\/span> = 'manage_options';   <span style=\"color: red;\">$menu_slug<\/span>  = 'extra-post-info';   <span style=\"color: red;\">$function<\/span>   = 'extra_post_info_page';   <span style=\"color: red;\">$icon_url<\/span>   = 'dashicons-media-code';   <span style=\"color: red;\">$position<\/span>   = 4;    <span style=\"color: red;\">add_menu_page<\/span>( $page_title,                  $menu_title,                   $capability,                   $menu_slug,                   $function,                   $icon_url,                   $position ); } <\/pre>\n\n\n\n<p>At this point in your WordPress plugin development, you\u2019ve already started to use the WordPress plugin function to control what your plugin does.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Variable\/Function Name<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td>$page_title<\/td><td>The title shown in the web-browser when viewing your plugin page<\/td><\/tr><tr><td>$menu_title<\/td><td>The title for the menu button shown in the WordPress dashboard<\/td><\/tr><tr><td>$capability<\/td><td>manage_options allows only Super Admin and Administrator to view plugin<\/td><\/tr><tr><td>$menu_slug<\/td><td>URL to access plugin such as: \/wp-admin\/admin.php?page=extra-post-info<\/td><\/tr><tr><td>$function<\/td><td>The function that contains the code for what to actually display on your plugin page<\/td><\/tr><tr><td>$icon_url<\/td><td>Icon used in dashboard. You can use WordPress dash icons, or direct images like: $icon_url = plugins_url( \u2018extra-post-info\/icon.png\u2019 );<\/td><\/tr><tr><td>$position<\/td><td>Icon position in dashboard<\/td><\/tr><tr><td>add_menu_page<\/td><td>The WordPress function that hooks in and builds our plugin menu in the dashboard<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<div class=\"jumbotron\">\r\n<p>If you need a new home for your WordPress site, look no further than InMotion\u2019s <a href=\"https:\/\/www.inmotionhosting.com\/wordpress-hosting\">WordPress Hosting<\/a> solutions for secure, optimized, budget-friendly servers.<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>Fast &amp; Easy Transfers    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>Free SSLs    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>Hack Protection    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>Affordable<\/p>\r\n<p><a class=\"btn btn-primary btn-lg\" href=\"https:\/\/www.inmotionhosting.com\/wordpress-hosting\">View WordPress Hosting Plans<\/a><\/p>\r\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"blank-page\">Blank Plugin Page Accessed from Dashboard Menu<\/h3>\n\n\n\n<p>At this point you should be able to see your WordPress plugin menu in the dashboard. If you click on it, you\u2019re just going to get a blank page as you haven\u2019t told WordPress what to put here yet. We\u2019ll be creating the Plugin Page next!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/admin-menu\/extra-post-info-plugin-page-blank.png\" alt=\"Our blank menu for the plugin is now visible in the dashboard. \"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"add-page\">Add WordPress Plugin Page<\/h2>\n\n\n\n<p>Your WordPress plugin page can just provide info to a user, or allow them to adjust the settings for how your plugin functions with their site.<\/p>\n\n\n\n<p>When you created a WordPress admin menu, one of the <span style=\"color: red;\">add_menu_page<\/span> options is <span style=\"color: red;\">$function<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">if( !function_exists(\"extra_post_info_menu\") ) { function extra_post_info_menu(){ ...   function   = '<span style=\"color: red;\">extra_post_info_page<\/span>'; ...   add_menu_page( $page_title,                  $menu_title,                   $capability,                   $menu_slug,                   <span style=\"color: red;\">$function<\/span>,                   $icon_url,                   $position ); } }<\/pre>\n\n\n\n<p>This defines the function WordPress will use when displaying your menu page for the plugin.<\/p>\n\n\n\n<p>In this example I named mine <span style=\"color: red;\">extra_post_info_page<\/span>. I can start by just setting a heading on my page.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">if( !function_exists(\"extra_post_info_page\") ) { function <span style=\"color: red;\">extra_post_info_page<\/span>(){ ?&gt;   &lt;h1&gt;WordPress Extra Post Info&lt;\/h1&gt; &lt;?php } } ?&gt;<\/pre>\n\n\n\n<p>The results of our code so far just displays some text on our plugin page.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/admin-menu\/extra-post-info-admin-page-with-just-heading.png\" alt=\"extra post info admin page with just heading\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"wp-form\">Save WordPress Plugin Settings with a Form<\/h2>\n\n\n\n<p>Now you can save WordPress plugin settings with a form so a user\u2019s settings are kept for later use. You want to take information typed into your plugin page and add it to the WordPress database so your plugin can read it. This allows your plugin users to alter settings for your WordPress plugin and customize it to fit their needs.<\/p>\n\n\n\n<p>You can use the built-in WordPress options page to gather info from the user, and then save it in our WordPress database in the <span style=\"color: red;\">wp_options<\/span> table. That way we can pull this info later to change what our plugin does on our site.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/admin-menu\/extra-post-info-admin-page-with-non-functional-form.png\" alt=\"extra post info admin page with non-functional form\"><\/figure>\n\n\n\n<p>In my example with the <span style=\"color: red;\">Extra Post Info<\/span> plugin, I want to allow users to type in the extra info for their posts. Then store that information in the WordPress database so we save what they typed in.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function extra_post_info_page(){ ?&gt;&lt;h1&gt;WordPress Extra Post Info&lt;\/h1&gt;\n&lt;form method=\"post\" action=\"options.php\"&gt;\n&lt;?php settings_fields( 'extra-post-info-settings' ); ?&gt;\n&lt;?php do_settings_sections( 'extra-post-info-settings' ); ?&gt;\n    &lt;table class=\"form-table\"&gt;&lt;tr valign=\"top\"&gt;&lt;th scope=\"row\"&gt;Extra post info:&lt;\/th&gt;\n    &lt;td&gt;&lt;input type=\"text\" name=\"extra_post_info\" value=\"&lt;?php echo get_option( 'extra_post_info' ); ?&gt;\"\/&gt;&lt;\/td&gt;&lt;\/tr&gt;&lt;\/table&gt;\n&lt;?php submit_button(); ?&gt;\n&lt;\/form&gt;\n&lt;?php }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"break-down\">Code Break-Down<\/h3>\n\n\n\n<p>We create a form and tell it to POST to the WordPress <span style=\"color: red;\">options.php<\/span> script, so WordPress can save our data.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;form method=\"post\" action=\"<span style=\"color: red;\">options.php<\/span>\"&gt;<\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We use the <span style=\"color: red;\">settings_fields<\/span> function, and pass <span style=\"color: red;\">extra-post-info-settings<\/span> as the group name we\u2019d like.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php <span style=\"color: red;\">settings_fields<\/span>( '<span style=\"color: red;\">extra-post-info-settings<\/span>' ); ?&gt;<\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We use the <span style=\"color: red;\">do_settings_sections<\/span> function, and pass the same group name to display our settings.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">&lt;?php <span style=\"color: red;\">do_settings_sections<\/span>( '<span style=\"color: red;\">extra-post-info-settings<\/span>' ); ?&gt;<\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We create a table and in the table header, we use <span style=\"color: red;\">Extra post info:<\/span> for the label of our field.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;th scope=\"row\"&gt;<span style=\"color: red;\">Extra post info:<\/span>&lt;\/th&gt;<\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We create a text input with the name set to <span style=\"color: red;\">extra_post_info<\/span>, and then we use <span style=\"color: red;\">get_option( \u2018extra_post_info\u2019 )<\/span> to display what\u2019s already been set in the database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;td&gt;&lt;input type=\"text\" name=\"<span style=\"color: red;\">extra_post_info<\/span>\" value=\"&lt;?php echo <span style=\"color: red;\">get_option('extra_post_info')<\/span>; ?&gt;\"\/&gt;&lt;\/td&gt;<\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We use the WordPress <span style=\"color: red;\">submit_button()<\/span> function to create a button to save our data.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php <span style=\"color: red;\">submit_button()<\/span>; ?&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"non-functional\">Plugin Page with Non-Functional Form<\/h3>\n\n\n\n<p>We now have enough logic in our plugin page to display a form, but it doesn\u2019t do anything yet.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/admin-menu\/extra-post-info-admin-page-with-non-functional-form.png\" alt=\"extra post info admin page with non-functional form\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"register-plugin\">Register Plugin Settings with WordPress<\/h2>\n\n\n\n<p>When you create a WordPress plugin, and you\u2019re already saving WordPress plugin settings with a form. You want to register those settings and store them in the database with WordPress, so it can change your site. To do this we need to register our setting changes with WordPress so it can store this information in the <span style=\"color: red;\">wp_options<\/span> table.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"add-action\">Add add_action Hook to Register Settings<\/h3>\n\n\n\n<p>When you create a WordPress admin menu you can add an <span style=\"color: red;\">add_action<\/span> function after the <span style=\"color: red;\">add_menu_page<\/span> function. This call another function <span style=\"color: red;\">update_extra_post_info<\/span> to save info to the database from our form.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <span style=\"color: red;\">add_menu_page<\/span>( $page_title,                  $menu_title, $capability, $menu_slug, $function,                   $icon_url, $position );\n<span style=\"color: red;\">add_action<\/span>( '<span style=\"color: red;\">admin_init<\/span>', '<span style=\"color: red;\">update_extra_post_info<\/span>' ); }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"register-settings\">Register Settings with register_setting Function<\/h3>\n\n\n\n<p>Creating a function called <span style=\"color: red;\">update_extra_post_info<\/span> you can use the WordPress <span style=\"color: red;\">register_setting<\/span> function to store info from our form into the database. The value will be stored next to <span style=\"color: red;\">extra_post_info<\/span> in the <span style=\"color: red;\">wp_options<\/span> table.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">if( !function_exists(\"update_extra_post_info\") ) { \nfunction <span style=\"color: red;\">update_extra_post_info<\/span>() {   <span style=\"color: red;\">register_setting<\/span>( '<span style=\"color: red;\">extra-post-info-settings<\/span>', '<span style=\"color: red;\">extra_post_info<\/span>' ); } }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"save-settings\">Plugin Settings are Now Saved to the WordPress Database<\/h3>\n\n\n\n<p>When you view your plugin page, you can see that when <span style=\"color: red;\">EXTRA INFO<\/span> is entered into our settings, it ends up in the WordPress database beside <span style=\"color: red;\">extra_post_info<\/span>. When this info is updated, so is the database entry.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/admin-menu\/extra-post-info-admin-page-register-setting-in-database.png\" alt=\"extra post info admin page register setting in database\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"read-settings\">Read WordPress Plugin Settings from Database<\/h2>\n\n\n\n<p>The final step to create your first WordPress plugin is to take the info that we registered with the WordPress database, and pull that into our plugin to change how it affects the site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"change-static\">Change Static Settings to be Database Driven<\/h3>\n\n\n\n<p>When we decided to create the main WordPress plugin function, we told WordPress what our extra post info should be. We hard-coded <span style=\"color: red;\">EXTRA INFO<\/span>, and to change it we\u2019d have to alter the plugin script manually each time.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">if( !function_exists(\"extra_post_info\") ) {    \nfunction extra_post_info($content)   {     \n<span style=\"color: red;\">$extra_info<\/span> = \"<span style=\"color: red;\">EXTRA INFO<\/span>\";     \nreturn <span style=\"color: red;\">$content<\/span> . <span style=\"color: red;\">$extra_info<\/span>;   }  \nadd_filter( 'the_content', 'extra_post_info' );  }<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"get-option\">Use WordPress get_option Function to Pull Info from Database<\/h3>\n\n\n\n<p>To allow our plugin users to change the info from the dashboard, and then have that info reflected across all our posts, we want to use the <span style=\"color: red;\">get_option<\/span> function to pull in the <span style=\"color: red;\">extra_post_info<\/span> data we stored.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">if( !function_exists(\"extra_post_info\") ) {    \nfunction extra_post_info($content)   {     \n<span style=\"color: red;\">$extra_info<\/span> = <span style=\"color: red;\">get_option<\/span>( '<span style=\"color: red;\">extra_post_info<\/span>' );     \nreturn <span style=\"color: red;\">$content<\/span> . <span style=\"color: red;\">$extra_info<\/span>;   }  \nadd_filter( 'the_content', 'extra_post_info' );  }<\/pre>\n\n\n\n<p>Now when a plugin user types in <span style=\"color: red;\">NEW INFO<\/span> into our plugin page, and clicks <strong>Save<\/strong>. The info is stored in the WordPress database, and then that new info is pulled into our posts.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.inmotionhosting.com\/support\/images\/stories\/wordpress-development\/plugins\/admin-menu\/extra-post-info-admin-page-read-setting-from-database.png\" alt=\"extra post info admin page read setting from database\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"completed\">Completed Extra Post Info WordPress Plugin<\/h2>\n\n\n\n<p>With the WordPress plugin we\u2019ve created, a user can update the info they want displayed on all posts from the dashboard. This is a very simple plugin, and just scratches the surface of the power of WordPress plugins. We hope it helped you understand how a WordPress plugin should be built. <\/p>\n\n\n\n<p>Here is a heavily commented version of the entire plugin so you can easily tell what\u2019s going on.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted cli\">&lt;?php <span style=\"color: #b8b8b8;\">\/* Plugin name: WordPress Extra Post Info Plugin URI: https:\/\/example.com\/wordpress-extra-post-info Description: A simple plugin to add extra info to posts. Author: Jacob Nicholson Author URI: https:\/\/InMotionHosting.com Version: 0.5 *\/  \/\/ Call extra_post_info_menu function to load plugin menu in dashboard<\/span> add_action( <span style=\"color: #00d343;\">'admin_menu'<\/span>, <span style=\"color: #00d343;\">'extra_post_info_menu'<\/span> );  <span style=\"color: #b8b8b8;\">\/\/ Create WordPress admin menu<\/span> <span style=\"color: #eee515;\">if<\/span>( <span style=\"color: #eee515;\">!<\/span><span style=\"color: #19a3e4;\">function_exists<\/span>(<span style=\"color: #00d343;\">\"extra_post_info_menu\"<\/span>) ) { <span style=\"color: #eee515;\">function<\/span> <span style=\"color: #ff8f00;\">extra_post_info_menu<\/span>(){    $page_title <span style=\"color: #eee515;\">=<\/span> <span style=\"color: #00d343;\">'WordPress Extra Post Info';<\/span>   $menu_title <span style=\"color: #eee515;\">=<\/span> <span style=\"color: #00d343;\">'Extra Post Info';<\/span>   $capability <span style=\"color: #eee515;\">=<\/span> <span style=\"color: #00d343;\">'manage_options';<\/span>   $menu_slug  <span style=\"color: #eee515;\">=<\/span> <span style=\"color: #00d343;\">'extra-post-info';<\/span>   $function   <span style=\"color: #eee515;\">=<\/span> <span style=\"color: #00d343;\">'extra_post_info_page';<\/span>   $icon_url   <span style=\"color: #eee515;\">=<\/span> <span style=\"color: #00d343;\">'dashicons-media-code';<\/span>   $position   <span style=\"color: #eee515;\">=<\/span> <span style=\"color: #00d343;\">4;<\/span>    add_menu_page( $page_title,                  $menu_title,                  $capability,                  $menu_slug,                  $function,                  $icon_url,                  $position );    <span style=\"color: #b8b8b8;\">\/\/ Call update_extra_post_info function to update database<\/span>   add_action( '<span style=\"color: #00d343;\">admin_init<\/span>', '<span style=\"color: #00d343;\">update_extra_post_info<\/span>' );  } }  <span style=\"color: #b8b8b8;\">\/\/ Create function to register plugin settings in the database<\/span> <span style=\"color: #eee515;\">if<\/span>( <span style=\"color: #eee515;\">!<\/span><span style=\"color: #19a3e4;\">function_exists<\/span>(<span style=\"color: #00d343;\">\"update_extra_post_info\"<\/span>) ) { <span style=\"color: #eee515;\">function<\/span> <span style=\"color: #ff8f00;\">update_extra_post_info<\/span>() {   register_setting( <span style=\"color: #00d343;\">'extra-post-info-settings'<\/span>, <span style=\"color: #00d343;\">'extra_post_info'<\/span> ); } }  <span style=\"color: #b8b8b8;\">\/\/ Create WordPress plugin page<\/span> <span style=\"color: #eee515;\">if<\/span>( <span style=\"color: #eee515;\">!<\/span><span style=\"color: #19a3e4;\">function_exists<\/span>(<span style=\"color: #00d343;\">\"extra_post_info_page\"<\/span>) ) { <span style=\"color: #eee515;\">function<\/span> <span style=\"color: #ff8f00;\">extra_post_info_page<\/span>(){ ?&gt;   <span style=\"color: #19a3e4;\">&lt;h1&gt;<\/span>WordPress Extra Post Info<span style=\"color: #19a3e4;\">&lt;\/h1&gt;<\/span>   <span style=\"color: #19a3e4;\">&lt;form method=<\/span><span style=\"color: #00d343;\">\"post\"<\/span> <span style=\"color: #19a3e4;\">action=<\/span><span style=\"color: #00d343;\">\"options.php\"<\/span>&gt;     &lt;?php settings_fields( <span style=\"color: #00d343;\">'extra-post-info-settings'<\/span> ); ?&gt;     &lt;?php do_settings_sections( <span style=\"color: #00d343;\">'extra-post-info-settings'<\/span> ); ?&gt;     <span style=\"color: #19a3e4;\">&lt;table class=<\/span><span style=\"color: #00d343;\">\"form-table\"<\/span><span style=\"color: #19a3e4;\">&gt;<\/span>       <span style=\"color: #19a3e4;\">&lt;tr valign=<\/span><span style=\"color: #00d343;\">\"top\"<\/span><span style=\"color: #19a3e4;\">&gt;<\/span>       <span style=\"color: #19a3e4;\">&lt;th scope=<\/span><span style=\"color: #00d343;\">\"row\"<\/span>&gt;Extra post info:<span style=\"color: #19a3e4;\">&lt;\/th&gt;<\/span>       <span style=\"color: #19a3e4;\">&lt;td&gt;&lt;input type=<\/span><span style=\"color: #00d343;\">\"text\"<\/span> <span style=\"color: #19a3e4;\">name=<\/span><span style=\"color: #00d343;\">\"extra_post_info\"<\/span> <span style=\"color: #19a3e4;\">value=<\/span><span style=\"color: #00d343;\">\"&lt;?php<\/span> <span style=\"color: #19a3e4;\">echo<\/span> <span style=\"color: #00d343;\">get_option('extra_post_info'); ?&gt;\"<\/span><span style=\"color: #19a3e4;\">\/&gt;&lt;\/td&gt;<\/span>       <span style=\"color: #19a3e4;\">&lt;\/tr&gt;<\/span>     <span style=\"color: #19a3e4;\">&lt;\/table&gt;<\/span>   &lt;?php submit_button(); ?&gt;   <span style=\"color: #19a3e4;\">&lt;\/form&gt;<\/span> &lt;?php } }  <span style=\"color: #b8b8b8;\">\/\/ Plugin logic for adding extra info to posts<\/span> <span style=\"color: #eee515;\">if<\/span>( <span style=\"color: #eee515;\">!<\/span><span style=\"color: #19a3e4;\">function_exists<\/span>(<span style=\"color: #00d343;\">\"extra_post_info\"<\/span>) ) {   <span style=\"color: #eee515;\">function<\/span> <span style=\"color: #ff8f00;\">extra_post_info<\/span>($content)   {     $extra_info <span style=\"color: #eee515;\">=<\/span> get_option(<span style=\"color: #00d343;\">'extra_post_info'<\/span>);     <span style=\"color: #eee515;\">return<\/span> $content . $extra_info;   } }  <span style=\"color: #b8b8b8;\">\/\/ Apply the extra_post_info function on our content<\/span>   add_filter(<span style=\"color: #00d343;\">'the_content'<\/span>, <span style=\"color: #00d343;\">'extra_post_info'<\/span>);  ?&gt;<\/pre>\n\n\n\n<p>You can also grab the <a rel=\"noopener\" href=\"\/support\/images\/stories\/wordpress-development\/plugins\/extra-post-info.txt\">raw text<\/a> version to review and use as a reference. Ready to design your own plugin from scratch? Take a look at our <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/\" aria-label=\"WordPress tutorials (opens in a new tab)\" rel=\"noreferrer noopener\">WordPress tutorials<\/a> for some ideas!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide we&#8217;ll walk you through creating your very first WordPress plugin. This will just be a simple plugin that adds some extra info to all of your posts. Using these same steps you can design and implement your own WordPress plugins! Remember, this is just an instructional plugin meant to show you the<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4379],"tags":[],"class_list":["post-68224","post","type-post","status-publish","format-standard","hentry","category-plugins"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create a WordPress Plugin | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Did you ever wonder how a WordPress plugin works? Create a WordPress plugin yourself to better understand WordPress and learn plugin development!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a WordPress Plugin | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Did you ever wonder how a WordPress plugin works? Create a WordPress plugin yourself to better understand WordPress and learn plugin development!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-15T13:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-30T15:41:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"Create a WordPress Plugin: A Tutorial\",\"datePublished\":\"2021-03-15T13:00:00+00:00\",\"dateModified\":\"2023-10-30T15:41:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\"},\"wordCount\":2363,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-1024x538.png\",\"articleSection\":[\"WordPress Plugins\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\",\"name\":\"Create a WordPress Plugin | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-1024x538.png\",\"datePublished\":\"2021-03-15T13:00:00+00:00\",\"dateModified\":\"2023-10-30T15:41:32+00:00\",\"description\":\"Did you ever wonder how a WordPress plugin works? Create a WordPress plugin yourself to better understand WordPress and learn plugin development!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1.png\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1.png\",\"width\":1200,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a WordPress Plugin: A Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create a WordPress Plugin | InMotion Hosting","description":"Did you ever wonder how a WordPress plugin works? Create a WordPress plugin yourself to better understand WordPress and learn plugin development!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/","og_locale":"en_US","og_type":"article","og_title":"Create a WordPress Plugin | InMotion Hosting","og_description":"Did you ever wonder how a WordPress plugin works? Create a WordPress plugin yourself to better understand WordPress and learn plugin development!","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2021-03-15T13:00:00+00:00","article_modified_time":"2023-10-30T15:41:32+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1.png","type":"image\/png"}],"author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"Create a WordPress Plugin: A Tutorial","datePublished":"2021-03-15T13:00:00+00:00","dateModified":"2023-10-30T15:41:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/"},"wordCount":2363,"commentCount":7,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-1024x538.png","articleSection":["WordPress Plugins"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/","name":"Create a WordPress Plugin | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1-1024x538.png","datePublished":"2021-03-15T13:00:00+00:00","dateModified":"2023-10-30T15:41:32+00:00","description":"Did you ever wonder how a WordPress plugin works? Create a WordPress plugin yourself to better understand WordPress and learn plugin development!","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1.png","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2021\/03\/wordPressPluginCreation-1.png","width":1200,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Create a WordPress Plugin: A Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4379,"name":"WordPress Plugins","slug":"plugins","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/68224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=68224"}],"version-history":[{"count":46,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/68224\/revisions"}],"predecessor-version":[{"id":107503,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/68224\/revisions\/107503"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=68224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=68224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=68224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}