Mostrar logotipo de cabeçalho diferente com base na categoria?

Is there a way to show a different main logo in the header (top left) when browsing threads within a certain category or their sub categories? Thank you.

I believe the body includes a class category-{category here}, which you could use to change category specific CSS.

I don’t know how to execute a script after the page content have loaded (I’m interested to know that too!), but for changing the logo image, you could do this:

// in a condition like if category == "somecategory" then…
document.getElementById("#site-logo").src = settings.theme_uploads.logo_cat1;

where logo_cat1 is the variable name of a custom logo:
image

Eu também tive esse problema recentemente. Percebo que este é um tópico antigo, mas aqui está uma solução caso alguém se depare com ele.

Você pode usar CSS e utilizar as classes no elemento body para detectar em qual categoria você está.

// Não mostrar o logo regular do site
body.category-something #site-logo {
    display: none;
}

// Mostrar outra imagem no título
body.category-something .home-logo-wrapper-outlet {
    height: 50px;
    width: 100px;
    background-image: url($category-something-image);
}

Espero que faça sentido :slight_smile:

Eu acho que você precisaria colocar sua imagem no elemento <a>, caso contrário, o link do logotipo simplesmente colapsará.

// Mostra outra imagem no título
body.category-something .d-header .title a {
  ...
}

Ah, certo, eu estava focando principalmente nos seletores CSS. Obrigado por corrigir isso.

1 curtida