Hello. With a creak I comprehend the basics of php and here: added support for a custom sidebar on the page

if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Футер на странице записи', 'before_widget' => '', 'after_widget' => '', 'before_title' => '<div class="title">', 'after_title' => '</div>', )); 

and add it to the footer:

 <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Футер на странице записи") ) : ?> 

in principle, everything is fine and works, but how to add a check here, is the page the main one (execute if it is not), or is it at least a single page (execute if yes)? I, like, found all this, help to complete, please. Here is a check on the main page

 if( is_front_page() ){ } else { // не главная } 

but on a separate post

is_single();

  • if you are given an exhaustive answer, please tick it accepted ("tick" to the left of the answer). - aleksandr barakin

2 answers 2

Wordpress never really worked with, but I will offer my own version. I hope I understand you correctly

 <?php //Проверяем, что страница не является главной или является отдельной страницей ?> <?php if (is_front_page() === false OR is_single() === true): ?> <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar("Футер на странице записи")) : ?> <?php endif; ?> <?php endif; ?> 
  • Sumptuously! This is what you need, even though it was enough just to check the main :) thanks. Based on this, I can do other checks. To leave only one condition, you need to delete === false OR is_single ()? - malginovdesign
  • OR is_single() === true remove - S. Pronin
  • well, yes, I understood everything, thank you very much - malginovdesign

in the global array $_SERVER - the ['REQUEST_URI'] parameter contains information about where you are at the moment. You can check this variable.

  • Thank you, but it seems to me too difficult. After all, I just need to correctly enter the code from the third window into the line from the second window, observing the syntax. - malginovdesign