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.