Task next. If I’m on a page like this, then do something. All this needs to be done in the function.php file. I tried this:

if (is_category('recepty')) 

nothing comes out. When debugging var_dump(is_category('recepty')); returns false.

  • What are we talking about? About standard types of records or custom? - Basil Jimmy
  • Is there a difference? Generally about the standard. - Valentin Dranyy

3 answers 3

Good day!

Use wordpress filters in the functions.php file, you should use the add_action ('init', 'action_function_name_11') filter;

The link is available documentation.

Example ( functions.php file):

 function action_function_name_11() { // Действие... if(is_category()) { //что-то делаем с этой загруженной страницей } } add_action( 'init', 'action_function_name_11' ); 
  • Could be so. Thanks for the reply - Valentin Dranyy

Generally figured out. function.php does not know (does not always know) which category it is currently in. Therefore, the problem was solved immediately in two ways:

  1. ajax pass address, or

2

if ( strpos($_SERVER[HTTP_REFERER], 'recepty') !== false ) { // делать что-то если совпадение есть }

    Using is_page :

     if (is_page(ID/slug/массив параметров)) 
    • does not work returns false. ( - Valentin Dranyy