The more you work with WordPress or PHP in general, the more you will begin to make use of callback functions. In WordPress specifically, one of the more common use of callback functions would be with WordPress Hooks. The use of WordPress Actions and WordPress filters allow WordPress Developers to: add, modify, or remove existing functionality within the WordPress ecosystem. In order to do so, you need to attach a callback function to your desired hook. That callback function is responsible for the task at hand.
This is my first WordPress Tutorial. My goal here in this tutorial is to teach you how to create a WordPress plugin in a simple and organized way, with a focus on code isolation and consistency. By the time you’ve finished this tutorial, you’ll have a plugin shell created which you can use essentially as a boiler plate template for all of your future plugin ideas.
When I develop WordPress Plugins or WordPress Themes, I like to always consider organization and efficiency. Organization comes in many forms. In this article, I’d like to discuss hook organization.
There are times where you might not want an event to occur until another event has occurred; Or maybe you want to have an event conditionally occur before or after another event has occurred.
Controlling the quality of your uploaded image files in WordPress might be something to consider. By default, WordPress doesn’t upload images with 100% image quality. If you want higher quality images or lower image quality, then consider adding this snippet of code to a plugin file or your currently active WordPress theme’s
This is going to be a short post. Mainly just a quick snippet of code. If you’re a developer or feel savvy enough to dive into hooks, this is a quick and useful snippet of code.
I ran into a situation where I needed to apply a callback function to
the_title filter hook in WordPress. I thought this would be a simple task. After creating my callback function and assigning it to the
the_title filter hook, I thought it did exactly what I needed it to do. Except, then I noticed it was also applying the same filter to navigation items as well. Thus, breaking the layout.