Home › Forum › Problemi Vari con WP › Creare link ad una categoria
-
AutorePost
-
-
19 Ottobre 2008 alle 13:52 #8240TremisferoPartecipante
Salve gente,
vorrei creare un link ad una categoria molto semplice, e ottenere questo output:
< a href=”link-a-categoria” >Nome categoria< /a >
Vorrei ottenerlo senza l’esclusione di tutte le altre ma tramite l’identificazione di quella che mi interessa, magar tramite ID o nome.
Come?
-
19 Ottobre 2008 alle 13:55 #58641wollyAmministratore del forum
clikki sopra il nome della categoria e copi il link nella barra del tuo browser
-
19 Ottobre 2008 alle 14:29 #58642TremisferoPartecipante
Ok… se voglio però avere il permalink alla categoria, in modo che se anche modifico il nome il link resta sempre funzionante? Un tag che crei il link alla categoria da piazzare nel menù del sito e che resti lଠper sempre (ma non voglio usare il list_cat e andare per esclusione mostrando solo quella che mi serve: vorrei indicarne l’ID).
Praticamente sia link che nome visualizzati devono essere estratti dinamicamente tramite l’id.
-
19 Ottobre 2008 alle 14:36 #58643wollyAmministratore del forum
-
20 Ottobre 2008 alle 8:37 #58658TremisferoPartecipante
Ah sà¬, perfetto. Per visualizzare il nome in modo dinamico invece? Sempre senza dover fare un list e poi escludere tutte le altre, ma settando l’ID di quella che voglio estrarre?
-
20 Ottobre 2008 alle 8:43 #58659
-
20 Ottobre 2008 alle 9:00 #58660TremisferoPartecipante
Quindi mi stai suggerendo di settare come titolo da visualizzare la descrizione della categoria e poi di estrarla al posto del titolo effettivo?
-
20 Ottobre 2008 alle 9:08 #58661wollyAmministratore del forum
no ti ho dato due possibilità una semlice, che è quella che scrivi ed una più complessa con get_the_category da dove puoi estrarre quello che vuoi.
-
20 Ottobre 2008 alle 16:17 #58665TremisferoPartecipante
OK grazie sei stato gentilissimo
-
16 Agosto 2010 alle 12:22 #76306mitchPartecipante
No scusate, non ho mica capito dal codex come ottenere, anche fosse in modo non dinamico, l’url della categoria…
Purtroppo non conosco nè l’inglese nè il php.
Dovrei soltanto linkare una categoria da un post…
-
16 Agosto 2010 alle 13:05 #76308PaperPartecipante
No scusate, non ho mica capito dal codex come ottenere, anche fosse in modo non dinamico, l’url della categoria…
Purtroppo non conosco nè l’inglese nè il php.
Dovrei soltanto linkare una categoria da un post…
bhè, se ti serve solo il link, da inserire una volta all’interno di un testo e non t’interessa che sia dinamico come si diceva sopra, basta che fai come ha scritto Wolly nel suo primo reply.. o allo stesso modo, clicchi sopra il nome della categoria con il tasto destro e selezioni “copia indirizzo” (con firefox.. e voce analoga in altri browser) e poi lo incolli nel post.. o comunque nella casella per la creazione di un link ipertestuale se usi l’editor visuale.
-
16 Agosto 2010 alle 15:06 #76312mitchPartecipante
Grazie mille per la risposta tempestiva!
Ma dal pannello di amministrazione? Uso un url del tipo:
http://www.ilmaltese.it/wp-admin/categories.php?action=edit&cat_ID=8
…Diversamente, non uso un tema che presenti da qualche parte dei links alle categorie, quindi non saprei da dove copiare l’url…
-
16 Agosto 2010 alle 15:28 #76313PaperPartecipante
dipende dal tipo di permalink che usi.. con quelli di default è una cosa del genere:
http://www.nomesito.com/?cat=X (e al posto della X metti l’id della categoria interessata)
Altrimenti, se usi altre strutture, cosà¬:
http://www.nomesito.com/category/nomecategoria/
Quindi a seconda del tipo di permalink che usi, basta che metti un link come quelli che ti ho messo qui sopra, mettendo ovviamente il nome del tuo sito dopo http:// e nel primo caso, l’id categoria, mentre nel secondo, il nome.
-
16 Agosto 2010 alle 15:48 #76317mitchPartecipante
GRANDE! FUNZIA! …millemila grazie, davvero, avanzi una birra! (ho fatto molte molteplici prove seza successo)
-
28 Giugno 2011 alle 11:31 #85947mitchPartecipante
adesso mi servirebbe di linkare una categoria in modo dinamico, però dal codex non riesco a apire di dove devo inserire l’ID della categoria:
<?php get_category_link( $category_id ); ?>
le ho provate tutte (dove al posto di X il mio ID):
`<?php get_category_link( $category_id=”X” ); ?>
<?php get_category_link( $category_X ); ?>
<?php get_category_link( “X” ); ?>
<?php get_category_link( $X ); ?>
<?php get_category_link( X ); ?>`
poi ho visto tra gli esempi:
`
<?php
// Get the URL of this category
$category_link = get_category_link( $category_id );
?>
`
e quindi anche qui le ho provate tutte, le combinazioni di cui sopra… qualcuno sarebbe cosଠgentile da “tradurmi” sto pezzettino di codex?
…quel che cerco è una cosa tipo:
<a href="<?php link_categoria_da-ID ("X") ?>"> se clicchi apri la categoria con id X</a>
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.