找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 查看内容

解决WordPress无法使用the_content()方法输出内容

作者:模板之家 2020-11-30 15:54 105人关注

下面由WordPress教程栏目给大家介绍WordPress 无法使用the_content()方法输出内容的解决办法,希望对需要的朋友有所帮助!在使用WordPress里在一个页面里我使用the_content()方法来输出当前页面...

下面由WordPress教程栏目给大家介绍WordPress 无法使用the_content()方法输出内容的解决办法,希望对需要的朋友有所帮助!

在使用WordPress里在一个页面里我使用the_content()方法来输出当前页面的内容,但却显示为空,而标题,url等都没有问题

在网络上好像遇到这种情况的人很少只找到了一个说是可能是function里有函数覆盖了the_content方法

但我将function方法删除掉还是不行,然后我将代码全部删除掉只留这一句"<?php the_content()?>"

结果还是不行,无奈只能通过其他方式解决

解决方案:

使用$post对像里的属性“ <?php echo $post->post_content;?>”

下面是我的page.php里的所有内容

<?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( '404'); ?>
<?php endif; ?>
</div>
<!-- neirong end -->
<?php get_footer(); ?>

以上就是解决WordPress无法使用the_content()方法输出内容的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章!


路过

雷人

握手

鲜花

鸡蛋
来自: 网络收集

全部回复(0)