A simple, concise guide about all 3 and why non-coders should know about them.
I didn’t write this guide to teach you how to program; there are much better ones already written. This guide is to help regular WordPress users understand WordPress on a more “programmatic” level and to make changes to their site or know how to direct programmers/contractors to make changes to their site.
I know it sounds like none of this should ever be relevant to you but I’ll do my best to make it useful!
DISCLAIMER: I might not be using these terms and other terms in this guide in the most programmatically-correct way. This guide is written more in layman’s terms to make things easier to understand.
NOTE:
- If you want a theme that makes HOOKS and FILTERS easily-customizable for non-programmers, check out GeneratePress.
- Otherwise…if you are a programmer, my favorite is still Genesis.
ACTIONS
You can think of “actions” in WordPress as being a trigger. An “action” would be like a programmed execution of some function triggered by a user action.
Real world examples of ACTIONS:
- Send email to admin user when someone submits contact form.
- Purge website cache when content is updated.
- Run website backup when the time strikes midnight.
As you can see, nearly anything that a user can do can be a trigger. And nearly anything can be the action. Other creative examples below that you (or a plugin) can add to your website:
- SMS sent to your phone when your admin account logs in.
- Comments are closed any time a post reaches 100 comments.
- Dates are hidden from byline once blog posts reach a certain period.
- Showing pop-up when user closes the window.
- …lol, this is hard. Every time I try to think of a creative “action”, it already exists by some plugin.
Why do regular WordPress users need to know about ACTIONS in WordPress?
Actually, you don’t. Hahaha. You’re not programmers and you’ll probably never have to program any trigger or action in WordPress or ever have to explain it to a programmer. I only include here it because it’s in the same conversation as “HOOKS” and “FILTERS”, which are much more relevant to regular WP users.
HOOKS
“Hooks” in WordPress are basically layout positions. If you look at many comprehensive themes…they’ll have many “hooks” available.
Examples of typical “HOOKS” positions below:
- above menu
- below menu
- above header
- header
- below header
- above content
- content
- below content
- above footer
- in footer
- below footer
And how you take advantage of these HOOKS positions is that you can attach content, images, widgets, or whatever you like to those positions. For example, if you want to put a slider in the header area, simply program it to take the HEADER position.
Now what if you wanted a special message to go just above this slider? Easy, you simply program it to take the ABOVE HEADER position. Or what about if your theme had this box below the header but you wanted to move it to below the footer? Same idea, go into the code and move it from the BELOW HEADER position down to the BELOW FOOTER position! Or maybe you want the cool banner that shows on your home page to show on all your blog posts…yes, it can be done!
Examples of real-world HOOKS:
- Putting slider in homepage header.
- Showing newsletter sign-up box after every blog post (after content).
- Putting sales messages in small bar at very top of your site (above header).
- Putting promotional coupons just above the footer.
It’s genius, right? And the more comprehensively your theme is coded, the more HOOKS it will have available for you to hook your content into.
And from now on, if you ever wanted to make a change and add something somewhere, or remove something from your theme or layout…it’s simply a matter of seeing where it’s hooked. The best documented themes (like GeneratePress) will even have handy guides to show you visually.
Want to edit the placement of anything in your theme/design?
- Simply look up your theme documentation and see if there’s a hook for it.
- Best case scenario, there’s a simple way to do it and you only have to add a code snippet to your functions.php in your child theme.
- Worst case scenario, you have to dig around in the parent theme and manually cut-and-paste bits of code to move it elsewhere. (Yes, this is a hack and will be over-written if you update your theme.)
FILTERS
A “filter” is a design modification. You use it to change where and when things appear.
Examples of typical “filters”:
- Show SLIDER header only on home page.
- Show BREADCRUMBS only on blog posts.
- Hide COMMENTS on pages.
- Show COUPONS on product pages.
- Show LATEST content on older blog posts.
- Hide SIDEBAR on all blog posts.
- Do/Don’t show some specific thing on just one specific page.
- Do/Don’t show some specific thing on just one specific blog category.
Although “filters” act like a typical IF-THEN statement in programming, users can just think of it as “custom page layouts” in the WordPress world. Think of it as showing different page layouts and/or custom content depending on the page.
You can specify which pages are different (modified) in a number of ways:
- by specific post ID (great for a few pages, but cumbersome if you need for many)
- by post types (posts, pages, products, reviews, etc)
- by taxonomy (certain category, tag, or other subset of a post type)
- by number of comments (e.g. if certain post has more or less than specific # of comments)
- by some word in the string (e.g. if the word “spaghetti” is in the title)
- by page template (most themes already have something like “full-width”, “narrow”, “no-sidebar”)
- …there are so many more possibilities beyond this but I don’t cover the less common ones.
I recommend setting your filters by page template as that’s very easy and makes the option available if you want to apply it to other pages later. Whatever layout modification you want to make, save it as its own separate page template and then choose that template when editing your pages later.
Want to make your own page templates?
I don’t think you can easily do that yourself depending on the theme you’re using. But you can however ask a programmer to do it for you. It wouldn’t take the much time at all. Just be clear in what you want and don’t on which pages.
Leave a Reply