WordPress Plugin is a process used to add or extend the functionality which can be enabled or disabled, and it does not interfere with the software and its code.

WordPress is lightweight and smooth that increases the flexibility and reduces code, which might not be necessary for easy website functions.

Plugins are used to add custom features and functionalities that allow users to design the website as their specific requirements.

wordpress plugin

 Requirement:

 Steps to make our own WordPress Plugin:

  1. Go to the WordPress Installation -> WordPress/wp-content/plugins.
wordpress plugin 1
  • Then in the next step make a new folder inside the “plugins” folder and name it as “wordpressplugin”.
  • Next, make a new file inside the “wordpressplugin” folder and name it as “firstplugin.php”

wordpress plugin 3
  • Add Plugin Name enclosed in a PHP comment in the file.

     Code of our PHP file “firstplugin.php”.

  • Now, go to the WordPress Dashboard-> Plugins, where we can see our newly created plugin.
  • In the next step, we add some function to our first plugin. We have added an essential function which named as FirstPlugin() that prints “Hello to my First Plugin”, and it has a shortcode that allows this code to be placed on a WordPress Post Page.

Code:

  • Go to the Posts-> Edit or create a new post. Add the shortcode for the new Plugin.  Shortcode[FirstPlugin].
  • Open the website and open the post in which we added the shortcode or our plugin.
  • The plugin function can be used multiple times by using the shortcode various times.
  1. Check the updated output. We get the same sentences various times because we used the shortcode multiple times in the post.
wordpress plugin 10
  • Now, we have our Plugin which returns a value, and that can be used whenever we want to use it with the help of Shortcode.

Pin It on Pinterest

Share This