比我想象的还要复杂。可能不漂亮但是it works.
功能。php
function get_btf_link( $taxonomy = \'\', $post = false ){
if ( ! $post ) {
global $post;
}
$url = get_post_type_archive_link( $post->post_type );
$terms = get_the_terms( $post, $taxonomy);
if ( $terms ) {
foreach ( $terms as $term ) {
$url = $taxonomy;
break;
}
}
return $url;
}
单体式。php
<?php the_title(); ?> is a
<a href="<?php echo home_url() ?>/poses/<?php echo get_btf_link(\'level\') ?>/<?php $terms = wp_get_object_terms( $post->ID, \'level\', array(\'fields\'=>\'slugs\',)); echo strip_tags( $terms[0]); ?>">
<?php echo strip_tags(get_the_term_list($post->ID, \'level\')); ?>
</a>,
<a href="<?php echo home_url() ?>/poses/<?php echo get_btf_link(\'position\') ?>/<?php $terms = wp_get_object_terms( $post->ID, \'position\', array(\'fields\'=>\'slugs\',)); echo strip_tags( $terms[0]); ?>">
<?php echo strip_tags(get_the_term_list($post->ID, \'position\')); ?>
</a>,
<a href="<?php echo home_url() ?>/poses/<?php echo get_btf_link(\'focus\') ?>/<?php $terms = wp_get_object_terms( $post->ID, \'focus\', array(\'fields\'=>\'slugs\',)); echo strip_tags( $terms[0]); ?>">
<?php echo strip_tags(get_the_term_list($post->ID, \'focus\')); ?>
</a>