N
N
Nikita Ivanov2013-11-25 23:56:41
css
Nikita Ivanov, 2013-11-25 23:56:41

Custom css for specific wordpress post category?

There is the latest version of WordPress
There is a template
there is an "Option Tree" management plugin attached to it
wordpress.org/plugins/option-tree
How can I use this base to make sure that, for example, the entire site has one css file, the category with id 1 has another , a with id 2 is the third one.
In fact, only the colors will change.
Is there any plugin for this?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Larionov, 2013-11-26
@Zidar

Specifically, to solve the task, you need to modify the header.php file of the theme, where, depending on the category (if (is_category('name'))), load the appropriate CSS instead of the regular one. But this way is wrong.
The correct one is to add rules to the style file that apply only to a particular category. The body tag (if the theme is done properly) contains the appropriate classes (as an example):
In the style file, respectively, you can write:

body.category-bez-rubriki .тут-нужный-селектор {
 /* тут правила */
}

S
Sergey, 2013-11-26
Protko @Fesor

redefining all css for only two categories is somehow not reasonable. Better than selectors. wp has the ability to set a class for body depending on where you are.

S
sasha, 2013-11-26
@madmages

strange requests as for me, but in fact - multiselectors ala #one .two div to help.

A
Alexander Kulnev, 2019-12-08
@alexanderkulnyow

if( is_category( $category ) ){
wp_enqueue_style ....
}
https://wp-kama.ru/function/wp_enqueue_style

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question