Pass Data to Template Files in WordPress 5.5+

I’m a sucker for small useful programmer features. While most of the WordPress peeps are chockablock with opinions on Gutenberg blocks vs PAGE BUILDER OF CHOICE, I just want you to know that you can now pass some variable around in your template files. If you’ve looked at the PHP files in a theme, you may be familiar with functions like get_template_part().

But the thing is, that part wasn’t aware of things a valued you’d saved to something like $cool_var_for_better_theming. And that was a little bummer. But it turns out all the obvious functions in WordPress now let you do things like pass a useful variable into them. And that means your theme can have fewer parts that just contain a little more smarts. And that’s something I will always be in favor of.

Read the full post for examples and other relevant details 🤓


Add a Comment

Your email address will not be published. Required fields are marked *