我想显示我的分类和在该类别下的帖子在2列。Wordpress类别列表2列
我曾尝试用CSS解决它,但是结果并不好。
这里是我的代码:
<?php
$cat_id = get_query_var('cat');
$catlist = get_categories('hide_empty=0&child_of=' . $cat_id);
foreach($catlist as $categories_item) {
echo "<div class='half'>";
$cat_title = get_field('category_title' , 'category_' . $categories_item->term_id);
echo "<ol>";
echo '<h3><a href="' . get_category_link($categories_item->term_id) . '" ' . '>' . $cat_title .'</a> </h3> ';
query_posts(array(
'cat' => $categories_item->term_id,
'posts_per_page' => 9999,
'order' => 'ASC', //order ascending
'orderby' => 'title' //order by title
));
if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink();?>">
<?php the_title(); ?>
</a></li>
<?php endwhile; endif; ?>
<?php echo "</ol>"; echo "</div>"; ?>
<?php } ?>
任何想法?
在此先感谢! :)