如何排除帖子和滑块(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.
更多推荐
发布评论