Hello reader's today we discuss about "How to write a simple Plugin in wordpress".
If you want a to write own Plugin in WordPress there are some steps you must follow and these steps are mention below:
- Plugin name should be unique(the name should be related to the functionality of the Plugin or what the Plugin will do).
- Plugin Files:- Now in next step you should create a PHP file with a name derived from your chosen Plugin name. Again, try to choose a unique name. People who install your Plugin will place this PHP file in their WordPress Plugins directory in installation (usually wp-content/plugins/), so no two Plugins they are using can have the same PHP file name.
- Readme File-: It contain the description of your plugin.
Now write the below code into your php file. below comment contain your Plugin information Author name and Author URL, Plugin version, Plugin URL.
<?php
/**
* Plugin Name: Your Plugin Name
* Plugin URI: http://evontech.com
* Description: What your Plugin do
* Version: 1.0.0
* Author: Evon Tech
* Author URI: http://evontech.com
*/
?>
Below code defines that how to create a shortcode of your Plugin.
social-urls is the shortcode of the Plugin. You can use this short code where you want in your website.
<?php
function social_url(){
<!-- write your code here-->
<?php
}
add_shortcode('social-urls', 'social_url');
How to call Plugin shortcode:-
<?php echo do_shortcode( '[social-urls]' ); ?>
0 Comment(s)