I have theme and in header.php and I found this templates (see attached screenshot). But there is no content directory in template directory. Even I searched for those files (header-private.php and header-public.php) but can't found. Then how those templates loading? enter image description here

  • 1
    Hopefully I have correctly understood your question, and just a friendly reminder - please add the actual code into your post and not just a screenshot of the code - because when it's an image, it'll be cumbersome for us to type out the code.. ✌
    – Sally CJ
    Commented Apr 1, 2022 at 6:42

1 Answer 1


But there is no content directory in template directory.

Actually, with the following:

  • get_template_part( 'templates/content', 'header-private' );
  • get_template_part( 'templates/content', 'header-public' );

WordPress will search in the templates folder for content-header-private.php or content-header-public.php, and if found, it is loaded. Else, WordPress will attempt to load the content.php file instead.

So WordPress (or get_template_part()) will not search in a folder named content, and instead, the "content" part in templates/content means, "search for PHP files where the name begins with content- in the templates folder, and if none found, please load content.php if it exists".

Other examples that might help:

// loads content.php
get_template_part( 'content' );

// loads templates/content.php
get_template_part( 'templates/content' );

// loads templates/content-foo-bar.php OR templates/content.php
get_template_part( 'templates/content', 'foo-bar' );

// loads templates/content/foo-bar.php OR templates/content/foo.php
// i.e. the function will now search in the "content" (sub-)folder
get_template_part( 'templates/content/foo', 'bar' );

Check out the get_template_part() documentation for more details about (using) the function.

Even I searched for those files (header-private.php and header-public.php) but can't found.

If the templates folder does not have these files: content-header-private.php, content-header-public.php and content.php, then they might be in the parent theme if you are using a child theme, so try searching in the parent theme's templates folder.

And it's because get_template_part() will first search in the child and then parent theme, so the template that's loaded could be the one in the parent theme.

Technically though, it's actually locate_template() which searches and loads the template, so you might also want to check the function's documentation.

  • 2
    Also, if they're using a child theme these files could be in the parent theme. Commented Apr 1, 2022 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.