我用自定义post type ui插件创建了自定义post type“truck”。然后,我创建了两个自定义分类法“make”和“model”。我在模板中使用高级自定义字段以我想要的方式显示输出。我的一切都按照我想要的方式进行了。。几乎
我正在使用插件搜索;过滤器,允许按自定义分类法进行过滤。所以,当我尝试过滤结果时,我会将每个分类法都指向我创建的存档页面,但每次都只显示所有结果,这让我很头疼。我猜我把我的问题搞砸了,但我不确定。下面是我的代码,非常感谢您的帮助,谢谢
这是显示所有列表的存档页面。
<?php /* Template Name: TruckArchive */ ?>
<?php get_header(); ?>
<div id="container" class="truck-archive">
<div class="title-container">
<h1 class="truck-title"><?php the_title(); ?></h1>
</div>
<div class="row">
<div class="col-md-9">
<div id="content" role="main">
<?php if ( have_posts() ) : the_post; ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
<!-- new query ----- -->
<?php
// Example for adding WP PageNavi to a new WP_Query call
$paged = get_query_var(\'paged\') ? get_query_var(\'paged\') : 1;
$args = array(\'post_type\' => \'truck\', \'posts_per_page\' => 10, \'paged\' => $paged);
$mytrucks = new WP_Query( $args );
while ( $mytrucks->have_posts() ) : $mytrucks->the_post(); ?>
<div class="col-md-12 panel panel-default">
<div class="col-md-4 thumb title">
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(\'thumbnail\'); ?>
</a>
<?php endif; ?>
</div>
<div class="col-md-4">
<h5><?php the_title(); ?></h5>
<?php echo custom_field_excerpt(); ?>
<ul>
<li><b>Stock #:</b> <?php the_field(\'stock_number\'); ?></li>
<li><b>Engine Manufacturer:</b> <?php the_field(\'engine_manufacturer\'); ?></li>
<li><b>Engine Type:</b> <?php the_field(\'engine_type\'); ?></li>
<li><b>Horsepower:</b> <?php the_field(\'horsepower\'); ?></li>
<li><b>Transmission:</b> <?php the_field(\'transmission\'); ?></li>
</ul>
</div>
<div class="col-md-4">
<h4>Price: $<?php the_field(\'price\'); ?></h4>
<div contact-info-archive>
<span>Title</span><br>
<address>Address</address>
<span>Phone:Phone Number</span><br><br>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="btn btn-default">Learn More</a>
</div>
</div>
</div>
<?php endwhile; ?>
<div class="row">
<div class="col-md-12 text-left">
<?php wp_pagenavi( array( \'query\' => $mytrucks ) ); ?>
</div>
</div>
<!-- new query end -->
</div><!-- #content -->
</div>
<div class="col-md-3 search-filter">
<div class="panel panel-default">
<h4>Narrow Your Search</h4>
<?php echo do_shortcode( \'[searchandfilter taxonomies="model,make"]\' ); ?>
</div>
</div>
</div>
</div><!-- #container -->
<?php get_footer(); ?>
这是自定义分类页面“taxonomy model.php”
<?php
include(\'archive-truck.php\');
?>
这是我试图获取的自定义搜索结果页面,以显示所有自定义分类法存档卡车的所有搜索结果。php
<?php get_header(); ?>
<div id="container" class="truck-archive">
<div class="title-container">
<h1 class="truck-title">Search Results</h1>
</div>
<div class="row">
<div class="col-md-9">
<div id="content" role="main">
<?php $mytrucks = new WP_Query(array(
\'post_type\' => \'truck\'
)); ?>
<?php while ($mytrucks->have_posts()) : $mytrucks->the_post(); ?>
<div class="col-md-12 panel panel-default">
<div class="col-md-4 thumb title">
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(\'thumbnail\'); ?>
</a>
<?php endif; ?>
</div>
<div class="col-md-4">
<h5><?php the_title(); ?></h5>
<?php echo custom_field_excerpt(); ?>
<ul>
<li><b>Stock #:</b> <?php the_field(\'stock_number\'); ?></li>
<li><b>Engine Manufacturer:</b> <?php the_field(\'engine_manufacturer\'); ?></li>
<li><b>Engine Type:</b> <?php the_field(\'engine_type\'); ?></li>
<li><b>Horsepower:</b> <?php the_field(\'horsepower\'); ?></li>
<li><b>Transmission:</b> <?php the_field(\'transmission\'); ?></li>
</ul>
</div>
<div class="col-md-4">
<h4>Price: $<?php the_field(\'price\'); ?></h4>
<div contact-info-archive>
<span>Title</span><br>
<address>Address</address>
<span>Phone:Phone Number</span><br>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="btn btn-default">Learn More</a>
</div>
</div>
</div>
<?php endwhile; ?>
</div><!-- #content -->
</div>
<div class="col-md-3 search-filter">
<div class="panel panel-default">
<?php echo do_shortcode( \'[searchandfilter taxonomies="model,make"]\' ); ?>
</div>
</div>
</div>
</div><!-- #container -->
<?php get_footer(); ?>