There are several types of plugins in WordPress, that is shorcode and menuadmins
What I will share now is the type shorcode
Type shortcode is a plugin that can be pasted on a wordpress post or page.
The first thing to create a wordpress plugin is to make information about the plugin in the form of comments like this.
<?php
/*
Plugin Name: My First Plugin
Description: put code <b>[myfirstplugin][/myfirstplugin]</b> on post or page
Version: 1
Author: Muhammad Deril
Author URI: https://www.derillab.com
*/
This section is very important because wordpress system will not read as a plugin if there is no this information.
Next create a function line to display when the plugin is called.
function myfirst_plugin() {
$data = "It's myfirst wordpress plugin";
return $data;
}
You can develop it even better, such as displaying data from a database or from ajax.
I will discuss that in another post.
Next, so that the function can be called on a post or page, you must insert it into the function that wordpress has provided like this.
<?php
/*
Plugin Name: My First Plugin
Description: put code <b>[myfirstplugin][/myfirstplugin]</b> on post or page of wordpress
Version: 1
Author: Muhammad Deril
Author URI: https://www.derillab.com
*/
function myfirst_plugin() {
$data = "It's myfirst wordpress plugin";
return $data;
}
add_shortcode('myfirstplugin', 'myfirst_plugin');
Save as init.php and put on any folder you can write like myfirstplugin. Archive the file folder in zip format then install it.And to call your plugin put code [myfirstplugin][/myfirstplugin] on your post or page of wordpress
0 Comments