Have you ever wondered how to create a custom WordPress plugin and a custom WordPress widget, and you want to be able to embed your new custom WordPress widget in any page or post? If so, you my friend have come to the right place.
Keep reading and you will learn how to install a custom WordPress plugin and a custom WordPress widget. You will also learn how to insert aforementioned custom WordPress widget into any WordPress post or page.
If you’re cloning, in your wp-content/plugins directory run this:
git clone https://github.com/hack3r3d/percentager.git
Obviously if you forked it, you need to change the URL.
Let’s digress for one second. Why are we installing a WordPress plugin called “percentager”?
Figuring out the percent different between two numbers is something I have to do often. Embarrassingly, I have to think about how to do it for a minute. I can always come up with the correct answer, but it takes me longer than I think it should.
So instead of waiting to get smarter, I just created this little WordPress plugin and a custom WordPress widget, shown here.
This WordPress custom plugin consists of the following files.
- percentager.php is the bulk of the application. It’s the WordPress plugin.
- widget.php is the WordPress widget.
- js/percentager.js is the where the magic happens. It controls the user interface and does the actual percent calculation.
- css/percentager.css is where the styling is.
With the percentager custom WordPress plugin installed and activated, let’s add it to a post. You activated it right? If not, do that before continuing.
To add the percentager custom WordPress widget to a post or page, you have to install AMR Shortcode Any Widget. Do that.
Once you have the AMR Shortcode Any Widget installed and activated, go to Appearance -> Widgets. There you will now see “Widgets for Shortcodes.” You should also see the Percentager widget. Drag Percentager onto the “Widgets for Shortcodes” box.
Now Percentager is available to be included in a posts and pages.
Create a post and add this to the body in Text mode.
If you did everything correctly, and I didn’t mess up my instructions, you should see the Percentager widget in your new blog post. It’s a great way to customize pages and posts with custom WordPress plugins and widgets.
I hope you enjoyed this post. If you need help customizing your WordPress site, I’m available for hire, send me a message.