wordpress调用 多篇文章

调用多篇文章1get_posts()

<?php $posts = get_posts("numberposts=4&post_type=any&include=1,3,4,6"); if($posts) : foreach( $posts as $post ) : setup_postdata( $post ); ?>
<li>
	<h2><a title="<?php the_title();?>" href="<?php the_permalink(); ?>" target="_blank"><?php the_title();?></a></h2>
	<div class="thumbnail">
		<a title="<?php the_title();?>" href="<?php the_permalink(); ?>"><?php if((function_exists('has_post_thumbnail')) && (has_post_thumbnail())){$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()) );?><img src="<?php echo $thumbnail_src[0];?>"/><?php }else {?><img alt="<?php the_title();?>" src="<?php echo catch_that_image(); ?>"/><?php } ?></a>
	</div>
	<div class="views-con">
		<p><?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 100,"……"); ?></p>
	</div>
	<div class="views-read">
		<a title="<?php the_title();?>" href="<?php the_permalink(); ?>">阅读全文</a>
	</div>
</li>
<?php endforeach; endif; ?>

调用多篇文章2get_posts()

<?php $posts = get_posts("numberposts=4&post_type=any&include=103,100,4,6"); if($posts) : foreach( $posts as $post ) : setup_postdata( $post ); ?>

<li><a href="<?php the_permalink()?>	" title="<?php the_title();?>"><?php the_title();?></a></li>

<?php endforeach; endif; ?>

调用多篇文章new WP_Query


<?php

if ($ua){	
 $query = new WP_Query( array(
  	'post_type' => 'post', 
 	'post__in' =>  explode(',',$ua),
 	'ignore_sticky_posts' => 1,
   ));
}
if ($ub){
	
 $query = new WP_Query( array(
  	'post_type' => 'post',  
 	'cat'				=>$ub,
 	'posts_per_page'     =>$uc,
 	'ignore_sticky_posts' => 1,
   ));	
	
	}  
   
   
while ( $query->have_posts() ) : $query->the_post();			
?> 
 
<li><a href="<?php the_permalink()?>	" title="<?php the_title();?>"><?php the_title();?></a></li>

 <?php endwhile;?>   
<?php wp_reset_query(); ?>

 

 

预见

发表评论

:?::razz::sad::evil::!::smile::oops::grin::eek::shock::???::cool::lol::mad::twisted::roll::wink::idea::arrow::neutral::cry::mrgreen: