这里用到了wordpress的get_posts函数。
‘author’ —— 按作者数值编号排序 ‘category’ —— 按类别数值编号排序 ‘content’ —— 按内容排序 ‘date’ —— 按创建日期排序 ‘ID’ —— 按文章编号排序 ‘menu_order’ —— 按菜单顺序排序。仅页面可用。 ‘mime_type’ —— 按MIME类型排序。仅附件可用。 ‘modified’ —— 按后修改时间排序。 ‘name’ —— 按存根排序。 ‘parent’ —— 按父级ID排序 ‘password’ —— 按密码排序 ‘rand’ —— 任意排序结果 ‘status’ —— 按状态排序 ‘title’ —— 按标题排序 ‘type’ —— 按类型排序
实例:
?<?php /* 首页单页内容的调用 126 Feature Products 128 Catalogue Download 120 Service Center 132 Customized Service */ $arr = array(126,128,130,132); for($i=0; $i<count($arr); $i++){ ?> <div class="fl colum"> <h1><?php echo get_post($arr[$i])->post_title; ?></h1> <p><?php echo mb_strimwidth(strip_tags(apply_filters('the_content', get_post($arr[$i])->post_content)), 0, 120," ..."); ?></p> <span class="more"><a href="/?page_id=<?php? echo $arr[$i]; ?>" class="sub">Learn More</a></span> </div> <?php } ?>
摘自主题:compay-2
游客回答:(0)