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獲取除置頂文章之外文章的方法