WordPress通过id调用多篇文章

输入id用英文半角逗号分隔一下就可以连续的展示文章内容

<?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; ?>

相关文章:

  • 无相关文章