doushaju4901 2014-05-26 13:22
浏览 45
已采纳

Twitter-bootstrap-3和Wordpress帖子显示

Scratching my head over this one but it is probably simple? I cannot seem to figure it out. So I am showing blog posts using a custom theme I have made with Twitter-Bootstrap-3 but having a problem showing my posts in a grid.

so i have a latest post at the top which is fine. but below I am aiming to show a grid of posts so when a new one is added it naturally goes to the top, I also have a side bar on the right. so the grid of posts should be 3 across and then create a new row and so on. My posts are just creating new rows now matter if i set them to be say col-md-3?

    <?php endwhile; wp_reset_query(); ?>

            <h2 class="blog-title">Past Posts</h2>


             <div class = "col-md-3">

                <?php while(have_posts()) : the_post(); ?>
                <?php the_post_thumbnail( 'medium', $attr ); ?> 
                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                <p><?php the_excerpt(); ?></p>
                <p class="text-muted">Posted by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?></p>
                <p><?php comments_number( 'no responses', '1 response', '% responses' ); ?>.</p>
                 <hr>
                <?php endwhile; wp_reset_query(); ?>

From researching I guessing there is a requirement for a loop of some sort? I am unsure form my code where to begin with that...

  • 写回答

1条回答 默认 最新

  • duanlin6989 2014-05-26 14:03
    关注

    probably because you need to wrap each post is s col-md-3, not all of the in a single one?

    So have a look at this...

    <h2 class="blog-title">Past Posts</h2>
    
    <?php while(have_posts()) : the_post(); ?>
    <div class = "col-md-3">
        <?php the_post_thumbnail( 'medium', $attr ); ?> 
        <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
        <p><?php the_excerpt(); ?></p>
        <p class="text-muted">Posted by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?></p>
        <p><?php comments_number( 'no responses', '1 response', '% responses' ); ?>.</p>
        <hr>
    </div>
    <?php endwhile; wp_reset_query(); ?
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 机器学习简单问题解决
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写