the_content() doesn’t work in custom post type template

I created custom post type name “agencies”, and a file called “single-agencies.php”.
For some reason, the_content() doesn’t work, while the_title() does work.

Here’s the code:

Read More
<?php get_header( 'agency' ); ?>

<div class="popup-container">

  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>


      <?php

      the_title("<div class='entry-title'><h2>", "</h2></div>");

      the_content(); 

      var_dump(get_the_content()); // this outputs "String(0)"
      ?>


          <div id="carousel" class="flexslider">

            <ul class="slides">

              <?php

              if( have_rows('agencies_repeater') ):

                while( have_rows('agencies_repeater') ): the_row();

                $img_url = get_sub_field('agencies_add_img');


                  echo "<li><img src= '" . $img_url['url'] . "'/></li>";

                endwhile;

              else :

                echo "no rows found";

              endif;



              ?>

            </ul>

          </div><!--.flexslider-->



          <div id="slider" class="flexslider">

            <ul class="slides">

              <?php

              if( have_rows('agencies_repeater') ):

                while( have_rows('agencies_repeater') ): the_row();

                  $img_url = get_sub_field('agencies_add_img');


                  echo "<li><img src= '" . $img_url['url'] . "'/></li>";

                endwhile;

              else :

                echo "no rows found";

              endif;



              ?>

            </ul>

          </div><!--.flexslider-->


  </article>

</div><!--.popup-container-->

What’s going on here?

Related posts

1 comment

  1. check whether the_id() give post id or not if yes then we can get the content by post id as below

    <?php 
    $post_id=get_the_id(); // or $post_id='9' where 9 is the post id custom 
     $welcome=get_post(9);
                    $welcomcontent=$welcome->post_content;
                    $welcomtitle=$welcome->post_title;
                    $welcomcontent=$welcome->post_content;        
                    $welcomcontent=apply_filters('the_content',$welcomcontent);
                    $welcomcontent=str_replace(']]>',']]&gt', $welcomcontent);
             ?> 
            <?php echo get_the_post_thumbnail($post_id);?>//thumbnial on post
            <h2><?php echo $welcomtitle;?></h2>//post title
            <span><?php echo $welcomcontent;?></span>//post_content
    

Comments are closed.