如何进行wordpress调用多个分类生成首页cms布局?wordpress首页cms布局方法
来源:蚂蚁目录 浏览:889次 时间:2021-04-20 11:58:25
wordpress首页cms布局就需要调用多个分类的内容,一开始接触wordpress的时候这段代码是从另外一个主题里面借鉴过来的,用的是while循环,用的我百般不习惯。
后来直接抄了zblog的foreach循环,也不知道对不对,反正能用...
分享出来,可以互相参政。
PHP
<?php $themecateid = '1,2,3'; $flids = explode(',',$themecateid); foreach ($flids as $cid){ ?>
<?php <ul> query_posts('posts_per_page=8&caller_get_posts=1&orderby=rand&cat='.$cid);
while (have_posts()) : the_post(); echo '<li><a href="'.get_permalink().'"
title="'.$post->post_title.'" target="_blank">'.$post->post_title.'</a></li>';
endwhile; wp_reset_query(); </ul> ?> <?php } ?>以上代码的“1,2,3”为调用的分类id,里面的一层还是用了while循环。html代码结构可以任意调整。