M
M
Maxim Tyulpakov2019-03-19 12:13:45
WordPress
Maxim Tyulpakov, 2019-03-19 12:13:45

How to use wordpress conditional logic to display a script on all pages except for two specific ones?

Actually, everything was written in the question. There are a lot of pages, headings, categories. For specific categories, certain scripts are needed, which at the same time should not intersect with a common script that is suitable for all other pages ...
As I understand it, are there any priorities? Like if you're on a landing page, then the general ones don't apply anymore?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2019-03-19
@MaXComp

You yourself answered your own question))) With the help of conditional logic.
Using conditional logic. But! If you need to include a script on all pages, except for two specific ones, then instead of listing all the pages where they are needed, it is better to list those pages where they are not needed with "negation".

if(!is_page(array(5,6))):
// подключаем скрипты и стили
endif;

Pay attention to !is_page() here we say that if these are not pages with ID 5 or 6, then we include scripts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question