问题描述
这是我尝试制作的代码
<div class="row">
<div class="col-lg-3 col-md-12">
<div class="card">
<div class="card-body">
<form action="<?PHP the_permalink() ?>" method="GET">
<?PHP
$terms = get_terms([
'taxonomy' => 'topics','hide_empty' => false
]);
foreach ($terms as $term) :
?>
<label>
<input
type="checkBox"
name="topics[]"
value="<?PHP echo $term->slug; ?>"
<?PHP checked(
(isset($_GET['topics']) && in_array($term->slug,$_GET['topics']))
) ?>
/>
<?PHP echo $term->name; ?>
</label>
<?PHP endforeach; ?>
<button type="submit">Apply</button>
</form>
</div>
</div>
</div><!--end of col1 -->
<div class="col-lg-9 col-md-12">
<div class="row">
<?PHP
$courses = new WP_Query(
array(
'post_type' => 'courses',// This is the name of your post type - change this as required,'posts_per_page' => -1,'tax_query' => array(
array(
'taxonomy' => 'topics','field' => 'slug','terms' => $term->slug,'operator' => 'IN'
)
) // This is the amount of posts per page you want to show
)
);
while ( $courses->have_posts() ) : $courses->the_post();
// The content you want to loop goes in here:
?>
<div class="col-lg-6 col-md-12">
<div class="card shadow bounceIn"
style="margin-top: 10px; border: none; border-radius: 13px;">
<div class="card-header"
style="color: white; text-align: start; border-top-left-radius: 13px; border-top-right-radius: 13px; background-color: #EE225D; border:none;">
<h6 style="padding-bottom: 0; margin-bottom: 0;"><?PHP the_title(); ?></h6>
</div>
<div class="card-body"
style="padding-top: 20px; padding-bottom: 20px; color: #2B2365;">
<h6 style="font-weight: 700;"><?PHP the_field('full_name'); ?></h6>
<p><?PHP echo wp_trim_words( get_the_content(),30,'...' ); ?></p>
<a href="<?PHP the_permalink(); ?>"
style="float:right; color: #EE225D; background-color: transparent; border-color: #EE225D;">View
Course</a>
</div>
</div>
</div>
<?PHP endwhile;
rewind_posts();
wp_reset_postdata();
?>
</div>
</div><!--end of col2 -->
</div>
但是当我刷新页面时,它会继续尝试加载,而当我删除功能rewind_post时,它会加载页面,但过滤器无法正常工作,我看了很多视频试图解决该问题,但没有成功 代码说明 两列,其中有一个过滤器 第二列有帖子
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)