Home › Forum › Problemi Vari con WP › single.php non contiene l’info di categoria
-
AutorePost
-
-
15 Marzo 2008 alle 10:15 #6035TremisferoPartecipante
Ciao a tutti.
Ho un problema che mi sembra alquanto grave e irrisolvibile.
Ho un menu includato nell’header con tanti tasti quante sono le categorie del mio sito. Quanso ci si trova in una categoria o in una pagina statica specifica ho impostato con degli if che il tasto corrispettivo resti evidenziato per far capire che mi ci si trova all’interno della categoria.
Fin qui tutto ok. Funziona.
Il problema è che quando visualizzo un articolo singolo si apre il file single.php al quale non pare venga passata l’informazione sulla categoria di appartenenza dell’articolo stesso ma solo il suo contenuto. Quindi il menù non resta evidenziato sulla categoria di appartenenza dell’articolo.
Come fare?
-
15 Marzo 2008 alle 10:38 #51572SteveAglAmministratore del forum
Anche nella visualizzazione di articoli singoli il tag condizionale is_category viene impostato… perchè legato all’articolo, quindi forse è un problema del tuo codice o forse nel momento in cui lo esegui non ha ancora caricato la categoria…
Se posti su pastebin.com il codice possiamo provare a capirci qualche cosa.
-
15 Marzo 2008 alle 21:21 #51578TremisferoPartecipante
Ok ho risolto per il single.php. Ma se voglio visualizzare una lista articoli che contiene tutti gli articoli di tutte le categorie in ordine di data, come faccio a dare un if che mi permetta di colorare (ad esempio) il testo del titolo dei singoli articoli estratti di un colore diverso a seconda della categoria?
Porre:
style=”background-color: #<?php if(is_category(12)){print”ff0099″;}?>;”
non va…
-
15 Marzo 2008 alle 21:50 #51579andreaPartecipante
Prova di nuovo ad usare la funzione in_category(), che ti dice se il post corrente appartiene alla categoria, e non is_category(), che ti dice se la pagina corrente è l’archivio della categoria.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.