Include Files in a Theme

If you want to include files in a theme, you can use:


A better way would be to use get_template_part():


And that’s why:

get_template_part() is looking for the file in a child theme (if you use one). If this file does not exist, it uses the file from the parent theme. If you use:

get_template_part( 'sidebar', 'primary' );

The function would look for:

  • child theme sidebar-primary.php
  • parent theme sidebar-primary.php
  • child theme sidebar.php
  • parent theme sidebar.php