Visualizzazione 3 filoni di risposte
Visualizzazione 3 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › WP e Accessibilità › link ad una categoria
Ciao a tutti,
ho bisogno di avere l’url delle categorie che voglio io.
Per avere il nome della categoria funziona get_the_category_by_id(5)
ma non riesco a trovare la funzione per estrarre il link della categoria che vorrei io. Esiste una funzione particolare?
get_category_link(5)
NON funziona, mi restituisce solo la categoria corrente.
Graaazieeee
Questa è la soluzione, credo la meno giusta ma non ne ho trovate altre in rete
<?php wp_list_categories('include=5&title_li='); ?>
<?php wp_list_categories('include=7&title_li='); ?>
<?php wp_list_categories('include=8&title_li='); ?>
Anche perchè avrei bisogno solamente dell’url in modo da personalizzare le mie caselle…
http://codex.wordpress.org/Function_Reference/get_category_link
fai una cosa del tipo, array con gli id che vuoi un foreach che estra le url con la funzone dicui sopra e che le mette in un array et voilà ..
Bingo!!!!
<?php
$args=array(
'orderby' => 'name',
'order' => 'DESC',
'include' => '5,7,8'
);
$conta = 1;
$categories=get_categories($args);
foreach($categories as $category) {
echo '<div id="filtro_'.$conta++.'" class="link_ricerche_filtro">Filtra: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </div> ';
}
?>
</pre>
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0