我在页面模板中有一个自定义循环,可以通过给定的类别和标签按类别显示帖子。它有效,但在循环之上我需要显示页面本身的内容,即正常输入到 Wordpress 仪表板的内容。
我应该在我的模板中添加什么来显示这些内容?
我试过:
$id = $post->ID;
get_page($id);
// then my custom loop
它获取当前页面 ID,但没有内容。
最佳答案
在 WordPress 中,调用
<?php the_content(); ?>
将在使用该模板的页面上从 WYSIWYG 编辑器中提取内容,只要它在循环内。
最基本的示例可能如下所示:
<?php while (have_posts()) : the_post();/* Start loop */ ?>
<?php the_content(); ?>
<?php endwhile; /* End loop */ ?>
<!-- Enter your custom loop for displaying posts by category down here -->
更多信息在这里:http://codex.wordpress.org/Function_Reference/the_content
关于php - Wordpress 显示页面内容和循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13568155/