Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 最近的帖子乱七八糟_Php_Wordpress - Fatal编程技术网

Php 最近的帖子乱七八糟

Php 最近的帖子乱七八糟,php,wordpress,Php,Wordpress,我对我正在开发的模板中最近的帖子有点问题 这是原始的HTML代码 <div class="main-news"> <!-- general post container --> <div class="new"> <div class="new-content"> <div class="new-image"> <i

我对我正在开发的模板中最近的帖子有点问题

这是原始的HTML代码

<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>

/images/new-03.jpg“alt=“News”title=“Llamado Al-templo”>
圣殿骑士团
智利绝地学院的一只美洲驼在圣殿绝地圣殿重新聚集,绝地圣殿重新聚集在一起

entrada por:middaurus | 15/03/2016 | Comentarios(8)

这是wordpress的改编

<?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>

entrada por:| | Comentario/s

我有点迷路了,我找不到问题所在,尝试了不同的代码,但都是一样的

谢谢您抽出时间,祝您新年愉快:)


注:在HTML版本中,当我复制帖子时,它们不会弄乱问题是
HTML
结构和花括号问题

<?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 } ?>

entrada por:| | Comentario/s


请您替换上面的代码好吗?我希望这对您有帮助。

在三次结束div后,您必须关闭while循环的花括号,检查代码中的HTML结构是否不匹配。非常有用谢谢!!新年快乐:)!