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

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

藏色散人
Release: 2020-11-30 14:57:36
forward
5264 people have browsed it

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 ""

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 " post_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(); ?>
Copy after login

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template