wordpress获取置顶文章列表的方法:
<?php $my_query = new WP_Query( array( ‘cat’ => array(1), ‘posts_per_page’ => 2,’post__in’ => get_option(‘sticky_posts’))) ?>
<?php if($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post();?>
<li>
<h5><a href=”<?php the_permalink() ?>” target=”_blank” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h5>
<p><?php the_content(); ?></p>
<a href=”<?php the_permalink() ?>” title=””>查看详情</a>
</li>
<?php endwhile; else: ?>
<?php endif; ?>
wordpress获取除置顶文章之外文章的方法:
<?php $my_query = new WP_Query( array( ‘cat’ => array(1), ‘posts_per_page’ => 10, ‘post__not_in’ => get_option( ‘sticky_posts’) )); ?>
<?php if($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post();?>
<li>
<h5><a href=”<?php the_permalink() ?>” target=”_blank” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h5>
<p><?php the_content(); ?></p>
<a href=”<?php the_permalink() ?>” title=””>查看详情</a>
</li>
<?php endwhile; else: ?>
<?php endif; ?>
转载请注明:⎛蜗牛SEO⎞ » wordpress获取置顶文章列表的方法,wordpress获取除置顶文章之外文章的方法