Categories
PHP WordPress

Passing variables to get_template_part() template in WordPress

Local variables are not available in get_template_part() templates.

Instead of using global variables, template can be included with locate_template() function and all your variables will be available in the template file.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.