fbpx

Passing arguments to template files in WordPress 5.5

For years, theme developers wishing to pass data to template files have had to use less than ideal workarounds. This included the use of global variables, set_query_var(), the include( locate_template() ) pattern, or own version of get_template_part(), and so on.

Starting in WordPress 5.5, the template loading functions will now allow additional arguments to be passed through to the matched template file using a new $args parameter.

Affected functions get_header() get_footer() get_sidebar() get_template_part() locate_template() load_template()

To provide proper context, the related action hooks have also been updated to pass this new $args parameter.

get_header get_footer get_sidebar get_template_part_{$slug} get_template_part

Note: get_search_form() already accepts and passes additional arguments to

This post was originally published on this site

GET UP TO $500K IN BUSINESS FUNDING

Pin It on Pinterest

Share This
Xiphos Web Marketing

FREE
VIEW