Home › Forum › Problemi Vari con WP › Nome sezione al posto di "Blog Archive"
-
AutorePost
-
-
22 Novembre 2011 alle 0:44 #19834smartmousePartecipante
Salve, ho notato che il titolo degli articoli del mio blog riportano sempre la scritta “Blog Archive” nella proprietà title della pagina web. Andando a vedere nel template ho trovato il codice relativo che riporto qui sotto:
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
Ebbene, come posso toglierlo e magari sostituirlo con il nome della categoria in cui si trova l’articolo?
Grazie.
-
22 Novembre 2011 alle 13:35 #89964SteveAglAmministratore del forum
toglierlo basta togliere il blocco: <?php if ( is_single() ) { ?> » Blog Archive <?php } ?>
Per la seconda cosa.. sei sicuro che i tuoi articoli siao sempre e solo collegati ad una sola categoria?
-
22 Novembre 2011 alle 19:15 #89986smartmousePartecipante
No, possono essere di una categoria diversa, a seconda dell’articolo.
Perciò chiedevo come fare, altrimenti lo avrei sostituito e basta.
E’ una cosa fattibile?
-
22 Novembre 2011 alle 19:38 #89992SteveAglAmministratore del forum
La mia domanda era se un articolo appartiene sempre e solo ad una ed una sola categoria e non viene assegnato che ne so a due categorie contemporaneamente… è ovvio che la categoria cambi se no non le si userebbero
-
22 Novembre 2011 alle 21:38 #89997smartmousePartecipante
Scusami avevo letto di fretta. No, gli articoli appartengono solo ad una e una sola categoria.
C’è soluzione in questo caso?
-
23 Novembre 2011 alle 8:37 #89998SteveAglAmministratore del forum
SI prima della riga incriminata metti:
<?php
$terms = get_the_terms( get_the_ID(), 'category' );
$terms = array_shift($terms);
$categoria = $terms->name;
?>E cambi la riga cosà¬:
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { echo "» $categoria " } ?> <?php wp_title(); ?></title>
-
23 Novembre 2011 alle 20:29 #90012smartmousePartecipante
Ha funzionato! Grazie mille!
Solo un appunto: mancava un “;” dopo “$categoria” e andava usato “»” al posto di “»”.
Una curiosità : come sapevi di questo codice? Lo hai fatto tu o magari lo hai preso dal codex?
-
24 Novembre 2011 alle 14:05 #90030SteveAglAmministratore del forum
Il ; visto che c’è la chiusura php non è necessario riguardo al “sergente” non ho capito… il codice fatto la momento in base al rpoblema.
-
24 Novembre 2011 alle 17:26 #90055smartmousePartecipante
Wow, complimenti allora! Pensavo fosse una funziona presente nel codex che non conoscevo.
Riguardo il “;” ti assicuro che ci voleva (parlo però da profano) perchè mi dava errore:
Parse error: syntax error, unexpected ‘}’, expecting ‘,’ or ‘;’ in /xxx/wp-content/themes/coreleos/header.php on line 13
-
24 Novembre 2011 alle 18:13 #90064SteveAglAmministratore del forum
Opps si vero… non avevo visto la graffa… si voleva si :)qulle’if potrebbe venir scritto senza le graffe tanto esegue una sola riga dopo l’if… allora non servirebbe il ; SOrry
Sui complimenti grazie ma traducendo in italiano e sviluppando con WP dal 2005… diciamo che ho un po’ di pratica
-
24 Novembre 2011 alle 20:52 #90078smartmousePartecipante
Ok, grazie per l’aiuto.
E buon lavoro con WP!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.