在配置文件选项卡中添加柱结构(如网格)


Add columns structure (like a grid) in profile tab

在我的网站上,每个用户都有一个个人资料,在一个专用的个人资料选项卡中有其提交的帖子。

我用这个代码来显示帖子:

<?php while ($ultimatemember->shortcodes->loop->have_posts()) { $ultimatemember->shortcodes->loop->the_post(); $post_id = get_the_ID(); ?>
    <div class="um-item">
        <div  class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
        <?php if ( has_post_thumbnail( $post_id ) ) {
                $image_id = get_post_thumbnail_id( $post_id );
                $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
        ?>
        <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'thumbnail' ); ?></a></div>
        <?php } ?>
        <div class="um-item-meta">
            <span><?php echo sprintf(__('%s ago','ultimatemember'), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); ?></span>
            <span>dans: <?php the_category( ', ' ); ?></span>
            <span><?php comments_number( __('no comments','ultimatemember'), __('1 comment','ultimatemember'), __('% comments','ultimatemember') ); ?></span>
        </div>
    </div>

<?php } ?>

然而,在这里,每一篇帖子都会在一列中显示其特色图片。我试图在两到三个相邻的列中显示我的帖子,而不是只显示一列(比如网格)。我从这里开始,看看两列是否显示良好:

<?php while ($ultimatemember->shortcodes->loop->have_posts()) { $ultimatemember->shortcodes->loop->the_post(); $post_id = get_the_ID(); ?>
        <div id = "left" class="um-item">
            <div  class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
            <?php if ( has_post_thumbnail( $post_id ) ) {
                    $image_id = get_post_thumbnail_id( $post_id );
                    $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
            ?>
            <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'thumbnail' ); ?></a></div>
            <?php } ?>
            <div class="um-item-meta">
                <span><?php echo sprintf(__('%s ago','ultimatemember'), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); ?></span>
                <span>dans: <?php the_category( ', ' ); ?></span>
                <span><?php comments_number( __('no comments','ultimatemember'), __('1 comment','ultimatemember'), __('% comments','ultimatemember') ); ?></span>
            </div>
        </div>
        <div id = "right" class="um-item">
            <div style="height: 10px;  class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
            <?php if ( has_post_thumbnail( $post_id ) ) {
                    $image_id = get_post_thumbnail_id( $post_id );
                    $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
            ?>
            <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'thumbnail' ); ?></a></div>
            <?php } ?>
            <div class="um-item-meta">
                <span><?php echo sprintf(__('%s ago','ultimatemember'), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); ?></span>
                <span>dans: <?php the_category( ', ' ); ?></span>
                <span><?php comments_number( __('no comments','ultimatemember'), __('1 comment','ultimatemember'), __('% comments','ultimatemember') ); ?></span>
            </div>
        </div>
    <?php } ?>

用这个css:

 #left
        {
          width: 200px;
          float: left;
        }
        #right
        {
          margin-left: 200px;
        }
        .clear
        {
          clear: both;
        }

但是布局一团糟,所有东西都坏了。我该如何改进?我想要一个后网格:

Post 1     Post 2      Post 3
Post 4     Post 5      Post 6
Post 7     Post 8      Post 9
Post 10    Post 11    Post 11

感谢您的帮助和时间

为什么不直接使用一个表呢?如果你使用的是像bootstrap这样的CSS框架,你也可以应用类"col-md-4"。