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.
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.
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' ); 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:
2
if ( strpos($_SERVER[HTTP_REFERER], 'recepty') !== false ) { // делать что-то если совпадение есть }
Using is_page :
if (is_page(ID/slug/массив параметров)) Source: https://ru.stackoverflow.com/questions/615377/
All Articles