K
K
Katerrinka2018-06-17 21:19:31
WordPress
Katerrinka, 2018-06-17 21:19:31

How to change the header for the main page?

Hello. You need to make 2 options for the header, for the static page fron-page.php and for everything else. I created a special header, named the file two.php in the file I write:

<?php
/**
 * Template for front page.
 *
 * @package Easy_Commerce
 */

if ( 'posts' === get_option( 'show_on_front' ) ) :

  get_template_part( 'home' );

else :

  if ( true === apply_filters( 'easy_commerce_filter_home_page_content', true ) ) :

    get_template_part( 'page' );

  else :

    get_header('two'); //Вот здесь указываю, вроде нужный мне файл.

    get_footer();

  endif;

endif;

And it doesn't work, out of desperation I tried to replace get_header('two'); on get_template_part( 'two' );- by. The page is exactly the one that I need to display this header, checked with a label.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Sukhanov, 2018-06-18
@xazbix

https://codex.wordpress.org/Template_tags/get_header
[For a template named two, the header-two.php template will be added]
In general, I didn’t quite understand what and how you connect.
If you need a separate header for the main one, isn't it easier to just put a condition in header.php:

if( is_front_page() ){
   echo "Это главная шапка";
}
else {
   echo "это не главная шапка";
}

and work with 1 file?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question