Search code examples
wordpressinternal-server-errorcustom-wordpress-pages

Wordpress custom template gives error 505


I have created a new page template for specific pages in wordpress, I am able to select that from wordpress pages template selection but when browsing to the page I get error 500 rest of the site is working fine. Website is hosted on CDN and using W3 Total Cache plugin.

Below is the wordpress page template code:

<?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'); ?>

Solution

  • Try this code

    <?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'); ?>
    

    you didnt close the if ( empty($page_images) ) {