我有两个不同的页面,带有过滤器。这两个页面具有不同的布局和样式。
对于一个页面,我有三个不同的过滤器,其中输出和样式是相同的。
对于“新闻过滤器”,我需要一种不同的样式。所以我想我需要另一个循环?
如何输出两个不同的循环?我当前的功能。php是:
function misha_filter_function(){
$args = array(
\'orderby\' => \'date\', // we will sort posts by date
\'order\' => $_POST[\'date\'] // ASC или DESC
);
$args = array(
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'post_tag\',
\'field\' => $cat_id,
\'terms\' => $_POST[\'ownerfilter\'],
),
array(
\'taxonomy\' => \'post_tag\',
\'field\' => $cat_id,
\'terms\' => $_POST[\'locationfilter\'],
),
)
);
$args = array(
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'post_tag\',
\'field\' => $cat_id,
\'terms\' => $_POST[\'newsfilter\'],
),
)
);
$relation = \'AND\';
if( isset( $_POST[\'timefilter\'] ) )
$args[\'tax_query\'] = array(
\'relation\' => $relation,
array(
\'taxonomy\' => \'post_tag\',
\'field\' => $cat_id,
\'terms\' => $_POST[\'timefilter\']
),
);
$query = new WP_Query( $args );
if( $query->have_posts() ) :
while( $query->have_posts() ): $query->the_post(); ?>
<!-- post -->
<a href="<?php the_permalink()?>">
<div class="col-md-3 col-sm-6 ver-item">
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), \'full\' );?>
<div class="thumb" style="background-image:url(\'<?php echo $thumb[\'0\'];?>\');"></div>
<section>
<time><?php echo get_the_date();?></time>
<h3><?php the_title();?></h3>
<span><!-- underline --></span>
</section>
</div>
</a>
<?php endwhile;
wp_reset_postdata(); else :
echo \'Geen resultaten, probeer het opnieuw.\';
endif;
die();
}
add_action(\'wp_ajax_myfilter\', \'misha_filter_function\');
add_action(\'wp_ajax_nopriv_myfilter\', \'misha_filter_function\');
“newsfilter”的筛选结果需要获得不同的输出和样式。我该怎么做?
提前感谢,
托马斯。
我尝试将$args改为另一个名称,但没有成功。我还尝试添加一个全新的函数(news\\u filter\\u函数而不是misha\\u filter\\u函数)。