【发布时间】:2015-01-16 18:03:05
【问题描述】:
我找到了用于显示自定义帖子类型的元术语的代码。 但它将元数据显示为垂直列表。 我希望代码连续显示 CPT 元数据。 请问有什么帮助吗? 代码:
<?php
//get all taxonomies and terms for this post (uses post's post_type)
foreach ( (array) get_object_taxonomies($post->post_type) as $taxonomy ) {
$object_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'all'));
if ($object_terms) {
echo '- '.$taxonomy;
foreach ($object_terms as $term) {
echo '<p><a href="' . esc_attr(get_term_link($term, $taxonomy)) .
'" title="' . sprintf( __( "View all posts in %s" ), $term->name ) .
'" ' . '>' . $term->name.'</a><p> ';
}
}
}
?>
【问题讨论】: