显示列与行中的列表项

时间:2013-05-13 02:36:24

标签: php wordpress

我当前的Wordpress页面包含以下相关代码:

<?php $attorneys = get_posts(array(
    'post_type' => 'attorney',
    'numberposts' => -1,
    'orderby' => 'meta_value',
    'meta_key' => '_attorney_last_name',
    'order' => 'ASC'
));
$number_of_attorneys = count($attorneys); ?>
<ul>
    <?php foreach($attorneys as $attorney) : ?>
        <li>
            <a href="<?php echo get_permalink($attorney->ID); ?>">
                <?php echo $attorney->post_title;  ?>
            </a>
        </li>
    <?php endforeach; ?>
</ul>

显示结果如下:

Attorney A    Attorney B    Attorney C
Attorney D    Attorney E    Attorney F
Attorney G    Attorney H    Attorney I
etc.

在三列与行中显示结果的正确程序是什么?
像...

Attorney A    Attorney D    Attorney G
Attorney B    Attorney E    Attorney H
Attorney C    Attorney F    Attorney I

是否可以均匀地分布结果,以便如果我有30个结果,那么每列有10个结果?

DIV此代码包含在(DIV名称为team)内的CSS如下:

.post .team ul { list-style-type: disc; color: #007ff1; margin-left: 0px; }
.post .team ul + ul { margin-left: 30px; }  
.post .team ul li { padding-bottom: 10px; float: left; margin-right: 20px; width: 175px; list-style-position: inside;}
.post .team ul li:nth-child(3n) { margin-right: 0px; }
.post .team ul li a { color: #007ff1; font-size: 18px; line-height: 20px; }

0 个答案:

没有答案