页面模板突然没有显示the_content()

时间:2015-09-24 12:06:35

标签: php wordpress templates wordpress-plugin wordpress-theming

我的网站突然出现问题。

昨天,我网站上的商家页面模板停止显示the_content()副本。我当天早些时候更新了4个插件;联系表格7,Yoast SEO,Jetpack和Wordfence安全。我不能100%将这些作为问题的原因联系起来,因为我从未注意到遗漏的内容。它是由用户报告的。但是我知道内容显示在2天前,当然。

无论哪种方式,我都单独停用了我的所有插件,但内容并没有重新出现。

以下是页面模板的代码:

<?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">&lt; 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: &nbsp; </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>&nbsp; <?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(); ?>

有人发现任何明显的问题吗?我应该强调,在问题出现之前我没有以任何方式编辑它。

内容在所有其他模板上显示正常,只有这个有问题,但它是一个非常重要的页面。

您可以直接在此处查看其中一个受影响的网页:http://goo.gl/8L0kNU

1 个答案:

答案 0 :(得分:1)

我认为问题是你使用the_content();没有循环而没有循环它们无法获取页面内容。使用下面的代码并在它们之间编写代码,然后检查。

<?php
while ( have_posts() ) : the_post();
    // Write your code here
endwhile;
?>