I’ve suddenly had an issue with a site I run.
Yesterday, the Business Page template on my site stopped showing the_content() copy. I updated 4 plugins earlier in the day; Contact Form 7, Yoast SEO, Jetpack and Wordfence Security. I can’t 100% link these as the reason for the issue, because I never noticed the missing content. It was reported by a user. However I know the content was displaying 2 days ago, for sure.
Either way, I individually deactivated all my plugins, but the content didn’t reappear.
Below is the code for the page template:
<?php
get_header();
// Calculate the best link back
$taxonomy = reset(wp_get_post_terms( get_the_ID(), 'business' ));
$back_link = get_term_link( $taxonomy, 'business' );
?>
<?php $sidebar_class = ''; ?>
<?php if($background_image = ardee('business_header')) { ?>
<div class="business-header" style="background-image: url(<?php echo $background_image; ?>);">
<?php } else { ?>
<?php $sidebar_class .= ' business-sidebar-flush'; ?>
<div class="business-header business-header-missing">
<?php } ?>
<div class="container">
<div class="row">
<a href="<?php echo $back_link; ?>" class="btn feature-back bg-white t-blue">< Back to Listings</a>
</div>
</div>
</div>
<div class="container">
<div class="row business-wrapper">
<div class="business-main col-sm-7">
<h1 class="business-title"><?php the_title(); ?></h1>
<h5 class="business-subtitle"><?php echo ardee('business_address'); ?></h5>
<div class="business-content copy">
<?php the_content(); ?>
</div>
<?php if($gallery = ardee('business_gallery')) { ?>
<div class="box business-gallery">
<h4 class="box-title">Photos</h4>
<div class="modal-gallery business-gallery row">
<?php foreach($gallery as $image) { ?>
<div class="business-gallery-image col-sm-4">
<a href="<?php echo $image['url']; ?>" title="<?php echo esc_attr($image['title']); ?>"><img src="<?php echo $image['sizes']['business-thumb']; ?>" class="img-responsive"></a>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php if($facilities = ardee('facilities')) { ?>
<div class="box business-facilities">
<?php $facilities_title = ( ardee( 'facilities_title' ) ) ? ardee( 'facilities_title' ) : 'Facilities'; ?>
<h4 class="box-title"><?php echo $facilities_title; ?></h4>
<ul class="list-unstyled list-facilities copy">
<?php foreach($facilities as $facility) { ?>
<li><i class="fa fa-check"></i> <?php echo $facility['facility']; ?></li>
<?php } ?>
</ul>
</div>
<?php } ?>
<?php if( $documents = ardee('document_categories') ) { ?>
<?php foreach(ardee('document_categories') as $category) { ?>
<div class="box business-category">
<h4 class="box-title"><?php echo $category['title']; ?></h4>
<div class="business-files row">
<?php foreach($category['documents'] as $document) { ?>
<div class="business-gallery-image col-sm-4">
<a href="<?php echo $document['document_file']['url']; ?>" title="<?php echo esc_attr($document['document_title']); ?>" download><img src="<?php echo $document['document_thumbnail']['sizes']['business-thumb']; ?>" class="img-responsive"><span><?php echo $document['document_title']; ?></a>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php } ?>
</div>
<div class="business-aside col-sm-5">
<div class="business-sidebar <?php echo $sidebar_class; ?> box">
<?php if ( has_post_thumbnail() ) { ?>
<div class="business-logo-holder">
<?php the_post_thumbnail( 'business-logo', array( 'class' => 'business-logo img-responsive' ) ); ?>
</div>
<?php } ?>
<div class="business-information">
<?php if($meta = ardee('contact_number')) { ?>
<div class="business-details">
<i class="fa fa-phone t-blue"></i>
<strong><a href="tel:<?php echo str_replace(' ', '', $meta); ?>" title="Call business" class="t-gray"><?php echo $meta; ?></a></strong>
</div>
<?php } ?>
<?php if($meta = ardee('business_address')) { ?>
<div class="business-details">
<i class="fa fa-home t-blue"></i>
<strong><?php echo $meta; ?></strong>
</div>
<?php } ?>
<?php if($meta = ardee('contact_email')) { ?>
<div class="business-details">
<i class="fa fa-envelope t-blue"></i>
<strong><a href="mailto:<?php echo encrypt_email($email); ?>" title="Email business" class="t-gray"><?php echo encrypt_email($meta); ?></a></strong>
</div>
<?php } ?>
<?php if($meta = ardee('business_website')) { ?>
<div class="business-details">
<i class="fa fa-link t-blue"></i>
<strong><a href="<?php echo $meta; ?>" title="Visit website" class="t-gray"><?php echo $meta; ?></a></strong>
</div>
<?php } ?>
<?php if($facebook = ardee('social_accounts', 'facebook_url') || $twitter = ardee('social_accounts', 'twitter_account')) { ?>
<div class="business-details business-social">
<strong>Social Profiles: </strong>
<?php if($facebook = ardee('social_accounts', 'facebook_url')) { ?><a href="<?php echo $facebook; ?>" title="Visit Facebook Page" target=_"blank"><i class="fa fa-facebook-official"></i></a> <?php } ?>
<?php if($twitter = ardee('social_accounts', 'twitter_account')) { ?><a href="http://twitter.com/<?php echo $twitter; ?>" title="Visit Twitter Feed" target="_blank"><i class="fa fa-twitter"></i></a><?php } ?>
</div>
<?php } ?>
</div>
<?php if($business_email = ardee('contact_email')) { ?>
<div class="business-contact">
<h4>Contact Business</h4>
<?php echo do_shortcode('[contact-form-7 id="4" title="Business Contact Form"]'); ?>
</div>
<?php } ?>
</div>
<?php $open_hours = reset( ardee( 'open_hours' ) ); ?>
<?php if( $open_hours['monday'] || $open_hours['tuesday'] || $open_hours['saturday'] || ardee( 'lunch_hours' ) ) { ?>
<div class="business-opening">
<h4>Opening Hours</h4>
<dl class="business-hours">
<?php if( $open_hours['monday'] || $open_hours['tuesday'] || $open_hours['saturday'] ) { ?>
<?php foreach($open_hours as $opening_day => $opening_hours) { ?>
<?php if($opening_hours) { ?>
<div class="business-timeslot <?php echo business_open_status($opening_day, $opening_hours); ?>">
<span class="pull-right"><?php echo $opening_hours; ?></span>
<?php echo ucwords($opening_day); ?>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
<?php if( ardee( 'lunch_hours' ) ) { ?>
<?php foreach(ardee('lunch_hours') as $opening) { ?>
<?php if($opening_hours['time']) { ?>
<div class="business-timeslot t-red">
<span class="pull-right"><?php echo $opening['time']; ?></span>
<?php echo $opening['title']; ?>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
</dl>
</div>
<?php } ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Anyone spot any glaring issues? I should stress that I didn’t edit this in any way prior to the issue.
The content appears fine on all other templates, it is only this one that has the issue, but it’s a very important page.
You can view one of the affected pages directly here: http://goo.gl/8L0kNU
I think the issue is you used
the_content();
without loop and without loop they can’t get the content of page. Use below code and write your code in between them and then check.