RIP
Tutorial
Tags
Topics
Examples
eBooks
Tutorial by Examples
Including a custom template
<?php get_template_part( 'foo' ); ?> Includes ../wp-content/themes/your-theme-slug/foo.php
Including a custom template with a dash-separated filename
<?php get_template_part( 'foo','bar' ); ?> Includes ../wp-content/themes/your-theme-slug/foo-bar.php
Including a custom template from inside a directory
<?php get_template_part( 'dir/foo' ); ?> Includes ../wp-content/themes/your-theme-slug/dir/foo.php
Including a custom template with a dash-separated filename located inside a directory
<?php get_template_part( 'dir/foo', 'bar' ); ?> Includes ../wp-content/themes/your-theme-slug/dir/foo-bar.php
Passing variable to custom template scope
<?php set_query_var( 'passed_var', $my_var ); get_template_part( 'foo', 'bar' ); ?> Access it in foo-bar.php <?php echo $passed_var; ?>
Page 1 of 1
1
Cookie
This website stores cookies on your computer.
We use cookies to enhance your experience on our website and deliver personalized content.
For more details on our cookie usage, please review our
Cookie Policy
and
Privacy Policy
Accept all Cookies
Leave this website