douda5227 2016-12-31 00:34
浏览 16
已采纳

最近的帖子凌乱的wordpress

I have a little problem with recent posts in a template what I'm developing

Screenshot

This is the original HTML code

<div class="main-news"> <!-- general post container -->

        <div class="new">
            <div class="new-content">
                <div class="new-image">
                    <img class="noselect" src="<?php bloginfo('template_directory');?>/images/new-03.jpg" alt="News" title="Llamado Al templo">
                </div>
                <div class="new-content-excerpt">
                    <h1>Llamado al Templo</h1>
                    <p>La Academia Jedi Chile llama a todos sus miembros a reunirse en el templo jedi para iniciar un periodo de entrenamiento y... </p>
                    <p class="entrada">Entrada por: Midtaurus | 15/03/2016 | <span class="mark">Comentarios(8)</span></p>
                </div>
            </div>
        </div>

    </div>

And this is the wordpress adaptation

<?php
    $recent_posts_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 3));

    while ($recent_posts_query->have_posts())
    {
    $recent_posts_query->the_post();
    ?>
<div class="main-news">
    <div class="new">
        <div class="new-content">
        <div class="new-image">
        <?php the_post_thumbnail();?>
    </div>
    <div class="new-content-excerpt">
    <h1><?php echo the_title(); ?></h1>
<?php the_excerpt();?>
    <p class="entrada">Entrada por: <?php the_author(); ?> | <?php echo the_date('d/m/y'); ?> | <span class="mark">Comentario/s</span></p>
</div>

    <?php
    }
    ?>
</div>
</div>
</div>

I'm kinda lost, I can't find what is the issue, tried different codes, but all do the same

Thanks for your time and have a nice new year :)

PS: In the HTML version when I duplicate the posts they don't mess up

  • 写回答

1条回答 默认 最新

  • dsa5233 2016-12-31 06:32
    关注

    The issue is HTML structure and curly bracket issue.

    <?php
    $recent_posts_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 3));
    
    while ($recent_posts_query->have_posts()){
        $recent_posts_query->the_post(); ?>
        <div class="main-news">
            <div class="new">
                <div class="new-content">
                    <div class="new-image"><?php the_post_thumbnail();?></div>
                    <div class="new-content-excerpt">
                        <h1><?php echo the_title(); ?></h1>
                        <?php the_excerpt();?>
                        <p class="entrada">Entrada por: <?php the_author(); ?> | <?php echo the_date('d/m/y'); ?> | <span class="mark">Comentario/s</span></p>
                    </div>    
                </div>
            </div>
        </div>
    <?php } ?>
    

    Would you please replace above code? I hope it's helpful for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog