我创建了帖子库,我使用了4种类型的分类法,我想用分页过滤所有帖子,但我的过滤器工作不正常。当我选择模型时 - >福特然后帖子没有显示在第一页,第二页显示。
<div class="gallery-section">
<div class="container">
<div class="fillter-head">
<div class="row">
<?php
$taxonomy = 'type_cat';
$tax_terms = get_terms($taxonomy, array('hide_empty' => false));
?>
<div class="col-md-8 col-sm-6 col-xs-12">
<ul class="filters" id="filters">
<?php
$count = count($tax_terms);
if ($count > 0) {
?>
<?php
foreach ($tax_terms as $term_single) {
$termname = $term_single->slug;
?>
<li><a href="#" data-rel="<?php echo $termname; ?>" data-filter=".<?php echo $termname; ?>" class="fil-type"><?php echo $term_single->name; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="gallery-menu">
<ul>
<?php
$make_taxonomy = 'make_cat';
$tax_makes = get_terms($make_taxonomy, array('hide_empty' => false));
?>
<li>
<a href="javascript:void(0)">MAKE</a>
<ul class="gallery-submenu" id="filters">
<?php
$count1 = count($tax_makes);
if ($count1 > 0) {
foreach ($tax_makes as $tax_make) {
$termname_make = $tax_make->slug;
?>
<li><a href="#" data-rel="<?php echo $termname_make; ?>" data-filter=".<?php echo $termname_make; ?>"><?php echo $tax_make->name; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
</li>
<?php
$model_taxonomy = 'model_cat';
$tax_models = get_terms($model_taxonomy, array('hide_empty' => false));
?>
<li><a href="javascript:void(0)">MODEL</a>
<ul class="gallery-submenu" id="filters">
<?php
$count_model = count($tax_models);
if ($count_model > 0) {
foreach ($tax_models as $tax_model) {
$termname_model = $tax_model->slug;
?>
<li><a href="#" data-rel="<?php echo $termname_model; ?>" data-filter=".<?php echo $termname_model; ?>"><?php echo $tax_model->name; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
</li>
<?php
$wheel_model_taxonomy = 'wheel_model_cat';
$tax_wheel_models = get_terms($wheel_model_taxonomy, array('hide_empty' => false));
?>
<li><a href="javascript:void(0)">WHEEL MODEL</a>
<ul class="gallery-submenu" id="filters">
<?php
$count_wheel_model = count($tax_wheel_models);
if ($count_wheel_model > 0) {
foreach ($tax_wheel_models as $tax_wheel_model) {
$termname_wheel_model = $tax_wheel_model->slug;
?>
<li><a href="#" data-rel="<?php echo $termname_wheel_model; ?>" data-filter=".<?php echo $termname_wheel_model; ?>"><?php echo $tax_wheel_model->name; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<?php
// Get a list of categories
$paged = ( get_query_var('paged') ) ? absint(get_query_var('paged')) : 1;
$args = array(
'post_type' => 'post_gallery',
'posts_per_page' => 9,
'order_by' => 'date',
'order' => 'ASC',
// 'paged' => $paged,
);
$new_query = new WP_Query($args);
// print_r($new_query);
?>
<div id="gallery" class="gallery">
<?php
if ($new_query->have_posts()) :
while ($new_query->have_posts()) : $new_query->the_post();
$terms = get_the_terms($new_query->ID, 'type_cat');
$terms_makes = get_the_terms($new_query->ID, 'make_cat');
$terms_models = get_the_terms($new_query->ID, 'model_cat');
$terms_wheel_models = get_the_terms($new_query->ID, 'wheel_model_cat');
$gallery_videos = get_field('gallery_videos');
$gallery_poster_images = get_field('gallery_poster_images');
?>
<!-- gallery item -->
<div class="item columns4 scale-anm <?php
if ($terms || $terms_makes || $terms_models || $terms_wheel_models):
foreach ($terms as $term) {
echo $term->slug;
}
foreach ($terms_makes as $terms_make) {
echo ' ' . $terms_make->slug;
}
foreach ($terms_models as $terms_model) {
echo ' ' . $terms_model->slug;
}
foreach ($terms_wheel_models as $terms_wheel_model) {
echo ' ' . $terms_wheel_model->slug;
}
endif;
?>">
<?php if ($gallery_videos): ?>
<div class="item-wrap">
<img src="<?php echo $gallery_poster_images; ?>" data-video="<?php echo $gallery_videos; ?>" class="videoPoster">
</div>
<?php else: ?>
<div class="item-wrap">
<a href="<?php echo get_permalink(get_the_ID()); ?>">
<?php the_post_thumbnail('gallery-page-img'); ?>
</a>
<div class="image_links hover-title"><a href="<?php echo get_permalink(get_the_ID()); ?>"><?php the_title(); ?></a></div>
<!--<div class="image_links hover-title"><a href="#">2016 Dodge Charger Hellcat ‘Plum Loca’ – FR5 Matte Graphite</a></div>-->
</div>
<?php endif; ?>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
<?php endif; ?>
<!-- close gallery item -->
</div>
<!-- <div class="gallery-pagination">
<ul class="pagination">-->
<?php if (function_exists("pagination")) { ?>
<?php pagination($new_query->max_num_pages); ?>
<?php } ?>
<!-- </ul>
</div>-->
</div>
</div>
这是我的PHP代码,工作正常,但我的过滤器无法正常工作。
请提出任何建议。
另外,我通过分页使用ajax,但我不知道它不起作用。
请任何人帮助我。