您现在的位置是:首页 > 教程 > WordPress教程WordPress教程
WordPress无法使用the_content()方法输出内容的解决方法
文子隐2023-07-27 22:52:38WordPress教程已有人查阅
导读在使用WordPress里在一个页面里我使用the_content()方法来输出当前页面的内容,但却显示为空,而标题,url等都没有问题
在使用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使用英文主题的方法
首先将wordpress源码放到xammp下的doc目录下,运行xammp(事先装好xammp),启动Apathe 和 mysqlwordpress采集的方法教学
WordPress是一种使用PHP语言开发的建站程序平台,现在做博客用wp的已经很多了,很多网站制作培训都使用的是wp,特别是在做采集站的时候wordpress的共能很强大。wordpress下载的主题为什么安装不了,WordPress主题安装失败的解决方法
wordpress下载主题怎么安装不了wordpress下载主题安装不了有两种原因:一是主题压缩包不是是zip格式;二是文件上传错误。WordPress主题安装失败的二个解决方法方法wordpress主题怎么保存
wordpress主题怎么保存,首先登陆wordpress的后台,然后找到wordpress后台的外观——主题
留言与评论 (共有 条评论) |