All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

How To Create Plugin In WordPress With Example

Last Updated : Mar 11, 2024

How To Create Plugin In WordPress With Example

In this article we will show you the solution of how to create plugin in WordPress with example, WordPress plugins can assist you in getting better your website. Numerous free ones are available, and you can even make your own unique WordPress plugins.

WordPress plugins function similarly to apps on your WordPress website.

WordPress plugins can be installed to add new features, just like mobile apps. You can also put your plugin through its paces on a test website.

Step By Step Guide On How To Create Plugin In WordPress With Example :-

Header code -

function tc_follow_us($content) {
// Only execute this when only one post is visible.
if (is_single() ) {
// Message to be displayed after the post
// Include URLs in your Twitter and Facebook profiles.
$content.= '<p class="follow-us">If you liked this article, then please follow us on <a href="http://twitter.com/talkerscode" title="TalkersCode on Twitter" target="_blank" rel="nofollow">Twitter</a> and <a href="https://www.facebook.com/talkerscode" title="TalkersCode on Facebook" target="_blank" rel="nofollow">Facebook</a>.</p>';
}
// Return the content
return $content;
}
// Connect our function to the content filter in WordPress.
add_filter('the_content', 'tc_follow_us');
functions.php code: -
<?php
/*
Plugin Name: TalkersCode Plugin Tutorial.
Plugin URI: https://www.talkerscode.com.
Description: We create TalkersCode plugin.
Version: 1.0
Author: TalkersCode.
Author URI: https://www.talkerscode.com.
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html.
Text Domain: TalkersCode-tutorial.
Domain Path: /languages
*/
  1. Create a new directory with a name like "tc-plugin" or "my-first-plugin" on their desktop or in your documents folder as the first step.How To Create Plugin In WordPress With Example
  2. Next, in your text editor, create a new file called tc-plugin.php or my-first-plugin.php and save it in your plugin folder. You are entirely free to choose the filename; only the .php extension is required.How To Create Plugin In WordPress With Example
  3. You must open that PHP file in your text editor.
  4. Your plugin file needs a plugin header, which you must include first. This comment block merely provides WordPress with information about your plugin's name, version, website, plugin author, and other details.
  5. The plugin code can then be added below the header after the header has been added.How To Create Plugin In WordPress With Example
  6. In this tutorial, we'll show you how to make a straightforward plugin that asks readers to follow us all on Twitter just at end of each article.
  7. Paste and copy the code below the header block of your plugin.
  8. Before saving your changes, don't forget to replace the URLs for your Twitter and Facebook profiles with your own.
  9. Create the zip file again for plugin folder on the desktop of your computer right away.
  10. Mac users can compress the wpb-plugin-tutorial folder by right clicking on it and selecting 'Compress tc-plugin'. Use the Send to »Compressed folder option from the context menu when using Windows to select the folder.How To Create Plugin In WordPress With Example
  11. Now that we've built the plugin, it's time to put it to the test.
  12. Go to your website's WordPress admin area and navigate to the Plugins »Add New site.How To Create Plugin In WordPress With Example
  13. To upload your plugin, click the 'Upload Plugin' button at the top. This displays a plugin upload box.
  14. Select a zip file visitor just created by clicking the Choose File button. Then, to upload but also install the plugin, click the Install Now button.
  15. After you've installed it, activate the plugin.How To Create Plugin In WordPress With Example
  16. You can now view a plugin in action by visiting your website. The new paragraph will be visible there at end of all their single posts.

Conclusion :-

As a result, we have successfully learned how to create plugin in wordpress with example.

To create a plugin, you'll need a basic understanding of coding languages such as PHP, CSS, HTML, and JavaScript.

You must have a local development environment in place once testing your WordPress installation on your computer.

I hope this article on how to create plugin in WordPress with example helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Ashish

Ashish is a dynamic and motivated individual with a passion of programming and an experienced programmer having 3+ years of experience in various languages like Java, Python, HTML, CSS, JavaScript, jQuery and various frameworks like Bootstrap

Follow Ashish On Linkedin 🡪