Supprimer un href de ce code
-
16-10-2019 - |
Question
J'utilise un petit morceau de code (qui est modifié, à l'origine, il était un plugin-Conditions Taxonomy Liste) pour afficher des taxonomies personnalisées après le poste,
Lorsque les termes sont affichés, il est affiché avec une étiquette de href
.
Je ne veux pas que les termes soient un lien, je veux juste texte des termes simples.
Comment puis-je obtenir?
Voici mon code actuel:
if( !function_exists( 'pr' ) ) {
function pr1( $var ) {
print '<pre>' . print_r( $var, true ) . '</pre>';
}
}
if( !function_exists( 'mfields_taxonomy_terms_list1' ) ) {
function mfields_taxonomy_terms_list1( $c ) {
global $post;
$o = '';
$terms = array();
$lists = array();
$custom_taxonomy_names = array();
$custom_taxonomies = mfields_get_custom_taxonomies1();
if( !empty( $custom_taxonomies ) )
foreach( $custom_taxonomies as $name => $config )
$custom_taxonomy_names[] = $config->name;
if( !empty( $custom_taxonomy_names ) )
$terms = get_terms( $custom_taxonomy_names );
foreach( $custom_taxonomies as $name => $config )
$o.= get_the_term_list( $post->ID, $name, $before = '', $sep = ' | ', $after = '' );
if( is_single() )
return $c . $o;
return $c;
}
add_shortcode('terms1', 'mfields_taxonomy_terms_list1');
}
if( !function_exists( 'mfields_get_custom_taxonomies1' ) ) {
function mfields_get_custom_taxonomies1( ) {
global $wp_taxonomies;
$custom_taxonomies = array();
$default_taxonomies = array( 'post_tag', 'category', 'link_category' );
foreach( $wp_taxonomies as $slug => $config )
if( !in_array( $slug, $default_taxonomies ) )
$custom_taxonomies[$slug] = $config;
return $custom_taxonomies;
}
}
add_action( 'wp_print_scripts', 'enqueue_slideout' );
La solution
Vous pouvez utiliser get_the_terms () au lieu: http://codex.wordpress.org/Function_Reference/get_the_terms
vous donne juste un tableau des termes associés. Ensuite, utilisez ce tableau pour créer votre propre liste sans liens.
Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange