我有一个崩溃的jQuery滑块,我被要求修复它。目前它正在加载128张幻灯片(当然会导致崩溃),但我们只想看到6张。
我尝试使用jQueryremove()
第7名及以上li
元素,但滑块仍为删除的元素加载空幻灯片。无论如何,我认为最好的解决方案是在模板代码中。
这些幻灯片是从具有从名为“特色项目”的高级自定义字段创建的复选框的帖子中提取的。当客户不想显示帖子时,要求或建议客户取消选中这些帖子不是一个选项。
你能帮我把代码改成只拉最近的6个吗?此外,我也希望有一个脚本,可以立即取消选中项目7及以上的复选框。
非常感谢。
/*
* Template name: Blog Landing
*/
global $faar_opt, $wp_query;
$acf_fields = get_fields();
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$categories = get_field(\'categories_of_blog\', $post->id);
// pretty sure this is what i need to modify, as it has \'featured_item\' (the checkbox)
$args = array(
\'post_type\' => \'post\',
\'posts_per_page\' => 8,
\'category__in\' => $categories,
\'meta_query\' => array(
array(
\'key\' => \'featured_item\',
\'value\' => \'1\'
)
),
);
$related_posts = new WP_Query($args);
$args = array(
\'post_type\' => \'post\',
\'posts_per_page\' => 4,
\'paged\' => $paged,
\'orderby\' => \'date\',
\'category__in\' => $categories
);
if(isset($wp_query->query_vars[\'blog_tag\'])){
$args[\'tag\'] = $wp_query->query_vars[\'blog_tag\'];
$current_tag = get_term_by(\'slug\', $wp_query->query_vars[\'blog_tag\'], \'post_tag\');
}
if(isset($wp_query->query_vars[\'blog_author\'])){
$current_author = get_user_by(\'login\', urldecode($wp_query->query_vars[\'blog_author\']));
$args[\'author\'] = $current_author->ID;
}
$all_posts = new WP_Query($args);
// each li is a slide, which is pulling 128, and needs to only be most recent 6
<ul class="slides blog-slides">
<?php
while($related_posts->have_posts()): $related_posts->the_post();
$author = get_user_by(\'id\', $post->post_author);
?>
<li>
// slide content (removed for simplicity. Tell me if you need it.
</li>
<?php endwhile; wp_reset_query(); ?>
</ul>