Formattazione get_terms () uscita funzione
-
16-10-2019 - |
Domanda
Il codice:
<?php the_terms($post->ID, 'type') ?>
Dà:
<a href="/archives/type/image" rel="tag">Tag</a>
Cosa fare per se voglio visualizzare solo la parola "tag", non collega ad es.
Tag
Grazie!
Soluzione
Mentre è possibile specificare i separatori e tale in argomenti the_terms()
, si presuppone che si vuole realmente collegamenti.
Si può scartare HTML indesiderati utilizzando il filtro:
add_filter('the_terms', 'no_terms_links', 10, 2);
function no_terms_links($term_list, $taxonomy) {
if ('type' == $taxonomy)
return wp_filter_nohtml_kses($term_list);
return $term_list;
}
o semplicemente usare più profondo get_the_terms()
funzione ed iterare attraverso il suo ritorno a costruire il proprio margine di profitto.
Altri suggerimenti
Nel corso di una super-super semplice scala, che dire semplicemente:
echo strip_tags( get_the_term_list($post->ID, 'type') )
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange