1

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.

enter image description here

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();
 ?>
1

Wrap the_content() function like below

$args = array(
  'post_type' => 'your-custom-post-type',
);
$query = new WP_Query( $args );
while( $query->have_posts() ):
   $query->the_post();
   the_content();
endwhile; wp_reset_postdata();

one thing to note here though, you must know where to end the loop ( i.e., endwhile; ) as you've other markup in the page template ( I assumed that above code belongs to post-template.php )

Another thing I noticed, if the post-template.php is template for about us page, then you can get content by

selecting respective page template for about us page in wordpress backend.

then,

while( have_posts() ):
  the_post();
  the_content();
endwhile; wp_reset_postdata();
1
  • post-template is in the includes directory, not the content/themes/... directory, so it's unlikely to be custom / to be related to the about page. – Julix May 6 '19 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy