Wordpress 给定设计的wp_柱未正确重复

Wordpress 给定设计的wp_柱未正确重复,wordpress,Wordpress,我使用Bootstrap4来设计博客页面。设计很好,但当我使用wp_帖子时,设计不能正常工作 <?php global $post; $events = array( 'post_type' => 'post', 'post_status' => 'publish', 'category_name' => 'events', 'posts_per_page' => 4, );

我使用Bootstrap4来设计博客页面。设计很好,但当我使用wp_帖子时,设计不能正常工作

<?php 
    global $post;
    $events = array(
        'post_type' => 'post',
        'post_status' => 'publish',
        'category_name' => 'events',
        'posts_per_page' => 4,
    );
    $arr_posts = new WP_Query( $events );

    $myposts = get_posts( $events );
    foreach ( $myposts as $post ) : setup_postdata( $post ); ?>

        <div class="row single-event">
            <div class="col-6 p-0 m-0">
                <?php
                    if ( has_post_thumbnail() ) :
                        the_post_thumbnail();
                    endif;
                ?>
            </div>
            <div class="col-6 event-desc">
                <a href="<?php the_permalink(); ?>" class="event-title d-block"><?php the_title() ?></a>
                <p class="exerpt">
                    <?php if ( is_category() || is_archive() ) {
                                echo excerpt(30);
                            } else {
                                echo content(30);
                            } 
                        ?>
                </p>
                <p class="date">Event Date: <span><?php echo get_the_date('F j, Y'); ?></span></p>
                <a href="<?php the_permalink(); ?>" class="btn btn-sm btn-outline-primary">Learn More..</a>
            </div>
        </div>

        <?php endforeach; 
    wp_reset_postdata();
?>

事件日期:

这是我的网站
请帮忙。提前感谢。

html代码在输出时似乎被破坏了。如果您使用开发人员工具检查您的网站,您将看到以下内容而不是输出:

    <div class="row single-event">
       <div class="col-6 p-0 m-0"></div>
       <div class="col-6 p-0 m-0"></div>
    </div>
    <div class="row single-event">
       <div class="col-6 p-0 m-0"></div>
       <div class="col-6 p-0 m-0"></div>
    </div>
    <div class="row single-event">
       <div class="col-6 p-0 m-0"></div>
       <div class="col-6 p-0 m-0"></div>
    </div>
然后试着替换

<p class="exerpt">
   <?php if ( is_category() || is_archive() ) {
          echo excerpt(30);
        } else {
          echo content(30);
        } 
   ?>
  </p>

与:


请使用下面的代码

<?php 
global $post;
$events = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'posts_per_page' => 4,
);
$arr_posts = new WP_Query( $events );

$myposts = get_posts( $events );
foreach ( $myposts as $post ) { setup_postdata( $post )?>

    <div class="row single-event">
        <div class="col-6 p-0 m-0">
            <?php
                if ( has_post_thumbnail() ) :
                    the_post_thumbnail();
                endif;
            ?>
        </div>
        <div class="col-6 event-desc">
            <a href="<?php the_permalink(); ?>" class="event-title d-block"><?php the_title() ?></a>
            <p class="exerpt">
                <?php if ( is_category() || is_archive() ) {
                            echo "test";
                        } else {
                            echo "test";
                        } 
                    ?>
            </p>
            <p class="date">Event Date: <span><?php echo get_the_date('F j, Y'); ?></span></p>
            <a href="<?php the_permalink(); ?>" class="btn btn-sm btn-outline-primary">Learn More..</a>
        </div>
    </div>

<?php } ?>

事件日期:


发生这种情况的唯一原因是EXPERT。如果我移除expert,那么它工作正常。当我把火用放进去的时候,它就这样被打破了。这种情况的发生仅仅是因为火用。html结构很好。
<p class="exerpt">
   <?php if ( is_category() || is_archive() ) {
          echo excerpt(30);
        } else {
          echo content(30);
        } 
   ?>
  </p>
<div class="exerpt">
   <?php if ( is_category() || is_archive() ) {
          echo excerpt(30);
        } else {
          echo content(30);
        } 
   ?>
  </div>
<?php 
global $post;
$events = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'posts_per_page' => 4,
);
$arr_posts = new WP_Query( $events );

$myposts = get_posts( $events );
foreach ( $myposts as $post ) { setup_postdata( $post )?>

    <div class="row single-event">
        <div class="col-6 p-0 m-0">
            <?php
                if ( has_post_thumbnail() ) :
                    the_post_thumbnail();
                endif;
            ?>
        </div>
        <div class="col-6 event-desc">
            <a href="<?php the_permalink(); ?>" class="event-title d-block"><?php the_title() ?></a>
            <p class="exerpt">
                <?php if ( is_category() || is_archive() ) {
                            echo "test";
                        } else {
                            echo "test";
                        } 
                    ?>
            </p>
            <p class="date">Event Date: <span><?php echo get_the_date('F j, Y'); ?></span></p>
            <a href="<?php the_permalink(); ?>" class="btn btn-sm btn-outline-primary">Learn More..</a>
        </div>
    </div>

<?php } ?>