档案中的多个分类法

时间:2014-01-02 22:05:51

标签: php archive taxonomy

我希望archives.php能够一次显示多个自定义分类。

现在,如果我写

,这是有效的
domain.com/?taxonomy=red&taxonomy2=circle

domain.com/?taxonomy=red+blue

但是,如何使我的分类法列表正确链接到此?现在我只能获得domain.com/?taxonomy=red而不能在URL中添加任何其他内容。

archives.php上的侧栏包含以下代码:

<?php

//First Query for Posts matching term1
$custom_terms = get_terms('taxonomy');

foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'taxonomy',
    'tax_query' => array(
        array(
            'taxonomy' => 'taxonomy',
            'field' => 'slug',
            'terms' => $custom_term->slug,
            'orderby' => 'title'
        ),
    ),
 );

 $loop = new WP_Query($args);
 if($loop->have_posts()) {
    echo '<li><a href="'.get_term_link( $custom_term, $taxonomy ).'">'.$custom_term-       >name.'</a>';
    echo '</li>';
 }
} 
?>

0 个答案:

没有答案