php - PHP Parse 错误:语法错误,迁移后出现意外的 'endwhile' (T_ENDWHILE)
问题描述
我目前正在尝试迁移我的朋友网站,它在 PHP 7.2.34 上构建的 Wordpress 上运行良好并且工作正常,但是当我将它移动到 Cloudways 时,在 PHP 7.2、7.1 或 7.4 上我得到了上面提到的错误。它使用的是二十九岁的儿童主题版本。如果有人能最终发现错误,而你会很棒!
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package WordPress
* @subpackage Twenty_Nineteen
* @since 1.0.0
*/
get_header();
?>
<section id="primary" class="content-area">
<main id="main" class="site-main">
<div class="post-repeat">
<?php /* Start the Loop */ while ( have_posts() ) : the_post();
// Display post media ?>
<div class="sunday-images">
<?php if (has_post_format('video', $post->ID)) { ?>
<?php
// Video post
$drive_id = get_post_meta( $post->ID, 'drive_id', true );
$poster_id = get_post_meta( $post->ID, 'poster_image', true );
$boomerang = get_post_meta( $post->ID, 'boomerang', true );
// returns array
$poster_image_attributes = wp_get_attachment_image_src ( $poster_id, 'large' );
// video wrapper
echo '<div class="videoWrapper ';
if ($boomerang == 'true'){
echo 'boomerang';
}
echo '">';
// video thumbnail image
echo '<video id="video" autoplay loop poster="' . $poster_image_attributes[0] . '">';
// video file hosted on google drive
echo '<source src="https://drive.google.com/uc?export=download&id=' . $drive_id . '" type="video/mp4">';
echo '</video>';
echo '</div>';
} else {
// Not a video post
if (get_the_post_thumbnail_url()) : ?>
<img src="<?php echo get_the_post_thumbnail_url(); ?>"/>
<? endif;
// if there is a gallery block do this
if (has_block('gallery', $post->post_content)) {
$post_blocks = parse_blocks($post->post_content);
foreach ($post_blocks as $block)
{
if ($block['blockName'] == 'core/gallery')
{
foreach ($block['attrs']['ids'] as $id)
{
$src = wp_get_attachment_image_src($id, 'large')[0];
echo '<img src="' . $src . '" />';
}
}
}
}
}
// Display episode number on image
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
echo '<div class="ep-num"><span>' . sos_get_episode_number($post->ID) . "</span> / " . $published_posts . "</div>";
?>
</div><!-- .sunday-images -->
<div class="content-toggle" id="<? echo $post->ID; ?>">
<?php
echo '<header class="title"><h1>' . get_the_title() . '</h1></header>';
get_template_part( 'template-parts/content/content', 'single' );
if ( is_singular( 'attachment' ) ) {
// Parent post navigation.
the_post_navigation(
array(
/* translators: %s: parent post link */
'prev_text' => sprintf( __( '<span class="meta-nav">Published in</span><span class="post-title">%s</span>', 'twentynineteen' ), '%title' ),
)
);
} elseif ( is_singular( 'post' ) ) {
$prev_post_obj = get_adjacent_post( '', '', true );
$prev_post_ID = isset( $prev_post_obj->ID ) ? $prev_post_obj->ID : '';
$prev_post_link = get_permalink( $prev_post_ID );
$prev_post_title = get_the_title($prev_post_ID);
if ($prev_post_ID)
{ ?>
<a href="<?php echo $prev_post_link; ?>" rel="previous" class="prev-post">
<?php echo $prev_post_title; ?>
</a> <?php
}
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
endwhile; // End of the loop. ?>
</div><!-- .content-toggle -->
</div><!-- .post-repeat -->
</main><!-- #main -->
<div class="page-load-status">
<div class="infinite-scroll-request">
<div class="loader-wheel">
<i><i><i><i><i><i><i><i><i><i><i><i>
</i></i></i></i></i></i></i></i></i></i></i></i>
</div>
</div>
</div>
</section><!-- #primary -->
<?php
get_footer();
当我通过上升气流移动访问该站点时,我收到以下错误
PHP Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE) in /home/519339.cloudwaysapps.com/yjarzhhcad/public_html/wp-content/themes/twentynineteen-child/single.php on line 126
任何帮助将不胜感激,谢谢大家!
解决方案
推荐阅读
- java - Java:如何以排序方式迭代 LinkedList?
- python - 连续查找第一次出现的负值
- python - 从 Python 中的数据流中提取携带信息的 12 位
- excel - 循环以确保输入框条目为八个字符长且为数字
- python - 对列表中的数据框列进行分组
- browser - 如何在电子浏览器中打开网站
- google-sheets - Google 表格 – 使用新的时间戳保存而不进行更改
- r - 如何将函数应用于数据框,然后应用于数据框列表?
- python - 在包含 QWidget 的相对于包含 QWidget 的坐标处添加 QWidget
- amazon-web-services - 如何在 AWS RDS 安全类中激活自动 IP 更改