Я использую короткий фрагмент кода (который изменен, изначально это был список терминов таксономии плагинов), чтобы отображать пользовательские таксономии после публикации,
Когда термины отображаются, они отображаются с href
тегом. Я не хочу, чтобы термины были ссылкой, мне нужен простой текст терминов.
Как я могу это получить?
Вот мой текущий код:
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' );
Вместо этого вы можете использовать get_the_terms(): http://codex.wordpress.org/Function_Reference/get_the_terms
Это просто дает вам массив связанных терминов. Затем используйте этот массив для создания собственного списка без ссылок.