如何排除帖子和滑块(How to exclude post and slider)

系统教程 行业动态 更新时间:2024-06-14 16:59:17
如何排除帖子和滑块(How to exclude post and slider)

我想加载后6日及以后。 以及如何在2页中排除滑块

我的主题代码home.php :

<?php if (have_posts()) : ?> <ul class="content"> <?php $counter = 0; while (have_posts()) : the_post(); $p = new Wpi_Article_Item(array( 'show_snippet' => true, 'show_category' => true, 'show_comment_number' => true, 'show_date' => true, 'category' => 1, 'snippet_length' => 200 )); echo '<li class="item item-' . $counter . ' item-' . (($counter == 0) ? 'first active' : 'other') . ' item-' . (($counter % 2) ? 'odd' : 'even') . (($counter % 3) ? '' : ' item-triple') . '"><div class="inner">'; echo $p->review() . $p->thumbnail('natural_full') . $p->cates() . $p->title() . $p->meta() . $p->snippet(true); echo '<div class="clear"></div></div></li>'; $counter++; endwhile; /* end have_posts */ ?>

I want to load post 6th and later. and How to exclude slider in 2 pages

My Theme code home.php:

<?php if (have_posts()) : ?> <ul class="content"> <?php $counter = 0; while (have_posts()) : the_post(); $p = new Wpi_Article_Item(array( 'show_snippet' => true, 'show_category' => true, 'show_comment_number' => true, 'show_date' => true, 'category' => 1, 'snippet_length' => 200 )); echo '<li class="item item-' . $counter . ' item-' . (($counter == 0) ? 'first active' : 'other') . ' item-' . (($counter % 2) ? 'odd' : 'even') . (($counter % 3) ? '' : ' item-triple') . '"><div class="inner">'; echo $p->review() . $p->thumbnail('natural_full') . $p->cates() . $p->title() . $p->meta() . $p->snippet(true); echo '<div class="clear"></div></div></li>'; $counter++; endwhile; /* end have_posts */ ?>

最满意答案

您可以在查询中使用偏移量。

<ul> <?php global $post; $args = array( 'numberposts' => 10, 'offset'=> 6, ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li> Your code here... </li> <?php endforeach; wp_reset_postdata(); ?> </ul>

并尝试你的代码。

You can use offset in your query.

<ul> <?php global $post; $args = array( 'numberposts' => 10, 'offset'=> 6, ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li> Your code here... </li> <?php endforeach; wp_reset_postdata(); ?> </ul>

And try your code.

更多推荐

本文发布于:2023-04-16 14:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/2e11ac31420e272d0f58f4539b756b72.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:滑块   帖子   exclude   post   slider

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!