在我的自定义帖子类型中,我想根据url中的参数进行过滤。例如?car=yellow&foo=1
是指元查询键和值。键和值是额外的字段。
这是我的循环现在的样子:
$args = array(
'post_type'=>'glas', // Your post type name
'posts_per_page' => 9,
'paged' => $paged,
);
$loop = new WP_Query( $args ); ?>
<?php if($loop->have_posts()): ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php echo get_field('type_glas'); ?> <?php echo get_field('uitvoering_glas'); ?><br>
<?php endwhile; ?>
<?php $total_pages = $loop->max_num_pages; ?>
<?php if ($total_pages > 1) : ?>
<?php
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
?>
<?php endif; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>