Formateo get_terms) salida de la función (
-
16-10-2019 - |
Pregunta
Este código:
<?php the_terms($post->ID, 'type') ?>
Da:
<a href="/archives/type/image" rel="tag">Tag</a>
¿Qué hacer para que si quiero mostrar sólo la palabra "etiqueta", se vincula por ejemplo.
Tag
Gracias!
Solución
Si bien puede especificar separadores y en tales argumentos the_terms()
, se supone que usted quiere realmente enlaces.
Se puede descartar HTML no deseado mediante el uso de 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 simplemente utilizar más profundo get_the_terms()
función e iterar a través de su regreso a construir su propia marca.
Otros consejos
En un requete escala simple, ¿qué pasa simplemente:
echo strip_tags( get_the_term_list($post->ID, 'type') )
Licenciado bajo: CC-BY-SA con atribución
No afiliado a wordpress.stackexchange