Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Well, purely mathematically, the header code in the main template will load a little faster, since if it is a separate file, then it must be read from the file system. On the other hand, using opcache in PHP or HHVM eliminates these losses. So, in reality, this is quite a nano-optimization. There won't be any noticeable difference. If you are really confused by optimization, then you have a lot of work to do, and this question is in 100,000th place. First optimization, and only then micro-optimization. Nano-optimization in the furnace. In most cases, there is no need for mere mortals to micro-optimize - the benefit is of the order of several milliseconds. On a real high-load, such things, in a complex way, allow you to save real dollars. But this is absolutely for large and highly loaded projects, which, by the way, are unlikely to be in PHP.
Well, it's not so easy to ignore the hat. The fact is that if there is no header.php file in the theme folder, WordPress will use its standard one, which is located in wp-includes/theme-compat/header.php
And in general, there are plenty of benefits from using the header.php template for a mere mortal. First, the modularity of templates, convenience. Especially when there are a lot of templates. Second, flexibility. The function get_header()
can take part of the file name as a parameter, so you can have different headers for different templates. For example, a large header with a slider on the main page, and a smaller version without a slider on the inner pages. And one more header for the 404 error page. Used like this:
// Подключить header.php
get_header();
// Подключить header-full.php
get_geader( 'full' );
// Подключить еще какой-то header-blah-blah.php
get_header( 'blah-blah' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question