user1250285
user1250285

Reputation: 15

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

Upvotes: 0

Views: 212

Answers (2)

Vel
Vel

Reputation: 9342

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) ) {

Upvotes: 1

Hareesh Sivasubramanian
Hareesh Sivasubramanian

Reputation: 1260

The 500 Internal Server Error could have been caused due to multiple reasons. A corrupt .htaccess file is one of the common issues.

You could try to rename the file by logging in to the FTP server. Also, visit the Permalinks page in the Settings menu and save the page to generate the rewrite rules.

Also, try to deactivate the cache plugin and check if the page works fine.

Upvotes: 0

Related Questions