我想顯示我的分類和在該類別下的帖子在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 } ?>
任何想法?
在此先感謝! :)