简体   繁体   中英

Can't get page content in WordPress

When I use the the_content() on page-about-us I can't get the content of the about us page from WordPress.

I got only below warning

Warning: count(): Parameter must be an array or an object that implements Countable in D:\\xampp\\htdocs\\megacity\\wp-includes\\post-template.php on line 284

Whats wrong with me? Please help me to find this.

在此处输入图片说明

i used only unyson plugin.

    <?php
    get_header();

    the_content();
    global $megacity;
    ?>

    <div class="container">
        <div class="row">        
          <div class="aboutus-section">
           <div class="col-md-4 left-block">
             <h2 class="title block_maintitle">about us</h2>
             <div class="description">
               <p><?php echo $megacity['megacity-about-us-desc']; ?></p>
               <div class="accordion_container">    
                 <?php 
                    // echo "<pre>";
                    // echo $megacity['megacity-about-us-dynamic-func'][0]['title'];
                    // echo "</pre>";

                    foreach( $megacity['megacity-about-us-dynamic-func'] as $key => $value ){
                      ?>
                        <div class="accordion_head"><span class="plusminus">+</span><?php echo $megacity['megacity-about-us-dynamic-func'][$key]['title']; ?></div>
                        <div class="accordion_body" style="display: none;">
                        <p>
                          <?php echo $megacity['megacity-about-us-dynamic-func'][$key]['description']; ?>
                        </p>
                        </div>
                      <?php
                    }
                 ?>
              <!-- <div class="accordion_head"><span class="plusminus">+</span>Health & Safety</div>
                <div class="accordion_body" style="display: none;">
                  <p>
                  Megacity Township is a prosperous wing and journey of unique Devlopers into Construction & Real Estate Business. unique Devlopers has built its own empire and earned a reputation of being successful in various fields of businesses in India as well as Abroad.
                </p>
                </div>

              <div class="accordion_head"><span class="plusminus">+</span>Drywall Technology</div>
                <div class="accordion_body" style="display: none;">
                  <p>
                  Megacity Township is a prosperous wing and journey of unique Devlopers into Construction & Real Estate Business. unique Devlopers has built its own empire and earned a reputation of being successful in various fields of businesses in India as well as Abroad.
                </p>
                </div> -->
       </div>
     </div>
   </div>
   <div class="col-md-7 right-block">
    <div class="vedio-block">
     <img src="<?php echo $megacity['megacity-about-us-img']['url']; ?> " >
   </div>
 </div>
</div>
</div>
</div>

<?php
    get_footer();
 ?>

It is caused by plugins or themes calling the_content() outside of the Loop, where $pages = null . This will cause php 7.2 to throw an error if attempting to count non-countable types.

In your case you must put your the_content() function inside the main loop like this:

if ( have_posts() ) {
    while ( have_posts() ) { the_post();

        the_content();

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM