Wordpress 自定义模板给出错误 505

Wordpress custom template gives error 505

我已经为 wordpress 中的特定页面创建了一个新的页面模板,我能够 select 从 wordpress 页面模板 selection 但是当浏览到该页面时我得到错误 500该网站工作正常。网站托管在 CDN 上并使用 W3 Total Cache 插件。

下面是wordpress页面模板代码:

<?php
/* Template Name: PackageDetails */
get_header(); ?>
<div class="container hds-custom">
    <div class="row">
        <div class="grey-bg clearfix">
            <div class="col-sm-6">
                <?php if ( have_posts() ) {
                    while ( have_posts() ) {
                        the_post();
                        the_content();
                    }
                }?>
            </div>
            <div class="col-sm-6">
                <?php $page_images =& get_children( array ( 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image' ));
                 if ( empty($page_images) ) { ?>
                 <h2>BOOKING AND RESERVATION (24/7)</h2>
                 <p>MOBILE NO: <a href="tel:+123456798">123456798</a> / <a href="tel:+123456798">123456798</a></p>
                 <?php echo do_shortcode('[contact-form-7 id="552" title="Booking &amp; Reservation"]')?>
                 <div class="alert alert-warning mt-1 mb-1">
                 Important note / Cancellation / Amendment / Refund policy:
                </div>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt, quam.</li>
                </ul>
            </div>
        </div>
    </div>
</div>
<?php get_footer('inner'); ?>

500 Internal Server Error 可能是由多种原因引起的。损坏的 .htaccess 文件是常见问题之一。

您可以尝试登录 FTP 服务器重命名该文件。另外,访问 Settings 菜单中的 Permalinks 页面并保存页面以生成重写规则。

另外,尝试停用缓存插件并检查页面是否正常。

试试这个代码

<?php
/*
Template Name: PackageDetails 
*/
get_header(); ?>
<div class="container hds-custom">
    <div class="row">
        <div class="grey-bg clearfix">
            <div class="col-sm-6">
                <?php if ( have_posts() ) {
                    while ( have_posts() ) {
                        the_post();
                        the_content();
                    }
                }?>
            </div>
            <div class="col-sm-6">
                <?php $page_images =& get_children( array ( 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image' ));
                 if ( empty($page_images) ) { ?>
                 <h2>BOOKING AND RESERVATION (24/7)</h2>
                 <p>MOBILE NO: <a href="tel:+123456798">123456798</a> / <a href="tel:+123456798">123456798</a></p>
                 <?php echo do_shortcode('[contact-form-7 id="552" title="Booking &amp; Reservation"]')?>
                 <div class="alert alert-warning mt-1 mb-1">
                 Important note / Cancellation / Amendment / Refund policy:
                </div>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt, quam.</li>
                </ul>
                <?php } ?>
            </div>
        </div>
    </div>
</div>
<?php get_footer('inner'); ?>

您没有关闭 if ( empty($page_images) ) {