我已经创建了一个自定义分类法“animal species”,我想过滤掉我的“animals”自定义帖子类型。这个想法是,用户可以进入主动物页面,通过猫、狗等过滤掉它们。我已经创建了一个动物物种分类法。php页面,但域。com/动物/?动物种类=猫(或狗或其他什么)仍然列出所有动物,而不仅仅是那些符合分类学的动物。我试着用我能想到的每一种变体重新命名分类页面,但没有成功。有人对如何解决这个问题有什么想法吗?
TLDR:域。com/动物/?动物种类=猫和域。com/动物/给出相同的结果
动物列表的代码。php页面和动物分类动物物种。php页面
<?php
            $page_link = get_permalink();
            $animal_species = get_terms( \'animal-species\' );
            $args = array();
            $args[\'post_type\'] = \'animal\';
            if ( isset( $_GET[\'animal-species\'] ) ) {
                $args[\'animal-species\'] = $_GET[\'animal-species\'];
                $page_link = add_query_arg( \'animal-species\', $_GET[\'animal-species\'], $page_link );
            }
            if ( is_array( $animal_species ) ) {
                echo \'<ul class="species_list">\';
                echo \'<li><a href="\' . htmlentities( remove_query_arg( \'animal-species\', $page_link ) ) . \'">Show all animals</a></li>\';
                foreach ( $animal_species as $animal_species ) {
                    echo \'<li><a href="\' . htmlentities( add_query_arg( \'animal-species\', $animal_species->slug, $page_link ) ) . \'">\' . $animal_species->name . \'s</a></li>\';
                }
                echo \'</ul>\';
            }
        ?>
            <div class="listing">
                    <?php 
                        $animals_per_page = 10;
                        if( function_exists( \'ot_get_option\' ) )
                        {                               
                            $animals_per_page = intval(ot_get_option(\'animals_per_page\'));
                        }
                        $args = array(
                                    \'post_type\' => \'animal\',
                                    \'posts_per_page\' => $animals_per_page,
                                    \'paged\' => $paged
                                );
                        $query = new WP_Query( $args );
                        $i = 0;                     
                        if ( $query->have_posts() ) 
                        {
                            while ( $query->have_posts() ) : 
                                $query->the_post(); 
                                $i++;
                                    ?>                          
                                    <div class="animal-item <?php if ($i % 2 == 0) { echo "even"; } ?>" >
                                        <?php get_template_part( \'inc/display-animal\' ); ?>                        
                                    </div>                           
                                    <?php
                            endwhile;
                        }
                ?>                          
            </div>