Home  >  Article  >  CMS Tutorial  >  Solve the problem that WordPress cannot output content using the_content() method

Solve the problem that WordPress cannot output content using the_content() method

藏色散人
藏色散人forward
2020-11-30 14:57:365227browse

The following is introduced to you by the WordPresstutorialWordPress Unable to use the_content() method to output content The solution, I hope it will be helpful to friends in need!

Solve the problem that WordPress cannot output content using the_content() method

When using WordPress, I use the_content() method to output the content of the current page on a page, but it is displayed as empty, while the title, url, etc. are all fine.

There seem to be very few people who have encountered this situation on the Internet. I only found one that said it may be that there is a function in the function covering the_content method

But I deleted the function method and it still didn’t work. , then I deleted all the code and left only this sentence "ae2c71cb3748333d02b5f92c6cb3929d"

The result still didn't work, but I had no choice but to solve it in other ways

Solution:

Use the attributes in the $post object " 5a9a6f4e0357efe1519ba782e2f10ea7post_content;?>"

The following is my page.php All content in

<?php
/** 内页/单页面
 * @author htl
 * @date 2014-01-28
 */
get_header();
?>
<?php get_sidebar()?>
<div id="neirong">
  <?php   if ( have_posts() ) :?>
    <h1><?php the_title();?></h1>
    <div id="content">       
      <?php 
        the_content()方法无法输出文章内容,通过$post对象里的post_content属性来输出
        //the_content();
        //print_r($post);
        echo $post->post_content;?>
    </div>
    <?php else : ?>
  <?php get_template_part( &#39;404&#39;); ?>
<?php endif; ?>
</div>
<!-- neirong end -->
<?php get_footer(); ?>

The above is the detailed content of Solve the problem that WordPress cannot output content using the_content() method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete