首页 > 解决方案 > 文件意外结束,期待 elseif (T_ELSEIF) 或 else (T_ELSE) 或 endif (T_ENDIF)?

问题描述

我在使用 WordPress 标签时遇到问题。创建标签并将标签附加到帖子后,URL 给我以下错误:

解析错误:语法错误,文件意外结束,在 /var/www/html/example.com/wp-content/themes/example/index.php 中需要 elseif (T_ELSEIF) 或 else (T_ELSE) 或 endif (T_ENDIF)第 30 行

这是我的 index.php 的代码:

<?php 
/*
Template Name: Blog Page
*/
get_header(); 
?>
        <!-- PAGE LAYOUT //-->
        <section id="page-title" style="background: url(<?php echo get_template_directory_uri().'/images/blog-title-bg.jpg'; ?>) no-repeat center top / cover;">
            <div class="page-wrapper">
                <h1>Our Blog</h1>
            </div>
        </section>
        <div id="page" class="interior"<?php if(get_field('content_background')) : ?> style="background: url(<?php echo get_field('content_background'); ?>) no-repeat center top / 100% auto;"<? endif; ?>>
            <div class="page-wrapper">
                <main>
                    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
                        <div class="blog-post">
                            <h3 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                            <div class="meta">Posted: <?php echo get_the_time('F j, Y'); ?> | By: <?php the_author(); ?></div>
                            <p><?php the_excerpt(); ?></p>
                            <p align="right"><a href="<?php the_permalink(); ?>">&raquo; Read More</a></p>
                        </div>
                    <?php endwhile; else : ?>
                        <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
                    <?php endif; ?>
                </main>
            </div>
            <?php get_sidebar('testimonials'); ?>
        </div>
<?php get_footer(); ?>

请任何指导将不胜感激。谢谢!

标签: phpwordpress

解决方案


推荐阅读