我正在制作一个页面模板,我需要the_title
与页面文本分开。我不知道如何加载the_content
没有标题。有人能帮忙吗?
WordPress Load Only Page Text
3 个回复
SO网友:1Bladesforhire
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
the_title( \'<h3>\', \'</h3>\' );// puts the title in h3 tags
the_content(); // adds the content
endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
请注意,只要标题函数位于if/while/the\\u post之后和endwhile之前,就可以在需要的地方使用标题函数;这是在不同区域检索标题和内容的方式。我无法对stackexchange的这一部分发表评论,但希望这能有所帮助。SO网友:Marta
很可能您有一个函数或插件正在将标题插入到您的内容中。
要检查这是否正确,请尝试使用get_the_content()
, 这是一个不通过the_content()
(重要信息:get_the_content()
不会扩展短代码)
SO网友:Owais Alam
以下代码仅加载页面模板的内容
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
the_content(); // show the content
endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>