Home › Forum › Problemi Vari con WP › Cerco una funzione tipo is_category però…
-
AutorePost
-
-
12 Agosto 2011 alle 19:09 #18856smartmousePartecipante
Devo aggiungere un controllo al mio sito, ovvero che quando visualizzo un post di una determinata categoria deve eseguire un determinato codice.
Ho cercato a lungo nel codex di WordPress ma l’unica funzione che più si avvicina a quello che cerco è quella in oggetto, ovvero “is_category”.
A me serve che la funzione deve controllare se mi trovo in un post (single) la cui categoria di appartenenza è quella da me impostata, invece la funzione sopra citata controlla solo se sto visualizzando o meno una categoria in generale (category).
Spero di essermi spiegato!
Conoscete un modo per risolvere?
Grazie.
-
12 Agosto 2011 alle 20:08 #87526wollyAmministratore del forum
basta mettere il controllo in single.php
-
12 Agosto 2011 alle 23:41 #87527smartmousePartecipante
Ed é proprio lଠche l’ho messa!
Altre idee?
-
13 Agosto 2011 alle 11:26 #87531smartmousePartecipante
Questo è il codice che ho inserito in single.php
<div class="postentry">
<?php the_content(__('Read the rest of this entry »')); ?><div style="clear:both;"></div>
<?php if (is_category('1')) {
the_excerpt_reloaded(15, '', 'none', TRUE, '<small>continua »</small>', FALSE, 2);
}
wp_link_pages(); ?>
</div>In questo modo la funzione excerpt, che è quella che voglio eseguire solo se si trova nella categoria 1, non viene mai eseguita…
Se tolgo il controllo if… compare ovunque.
Dove sbaglio?
-
13 Agosto 2011 alle 13:30 #87532wollyAmministratore del forum
in_category NON is_category
-
13 Agosto 2011 alle 19:26 #87537smartmousePartecipante
Wow! Ha funzionato!
Avevo già trovato quella funzione nel codex ma non l’avevo proprio provata per via del secondo parametro previsto.
Invece omettendolo la funzione fa proprio quello che volevo!
Grazie mille!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.