WordPress调用全站的置顶文章代码:
<?php $query_post = array(
posts_per_page => 5,
post__in => get_option(sticky_posts),
caller_get_posts => 1
);
query_posts($query_post);
?>
<?php while(have_posts()):the_post(); ?>
<li class="li1"><a href="<?php the_permalink() ?>">
<img src="<?php echo get_first_image(); ?>" width="197px" height="145px" /><span><?php the_title(); ?></span></a></li>
<?php endwhile; ?>
<?php wp_reset_query();?>
WordPress调用指定分类下的置顶文章代码:
<?php
$args = array(
post_type => post,
showposts => 3,
//orderby => rand,
post__in => get_option(sticky_posts),//获取置顶文章
cat => array(8),//指定分类id
);
?>
<?php
$catquery = new WP_Query($args);
while($catquery->have_posts()) : $catquery->the_post();
?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php wp_reset_query();?>
标签: