php - Wordpress 显示页面内容和循环?

标签 php wordpress-theming wordpress

我在页面模板中有一个自定义循环,可以通过给定的类别和标签按类别显示帖子。它有效,但在循环之上我需要显示页面本身的内容,即正常输入到 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/

相关文章:

奇怪标签 <# #> 内的 Php 代码

php - 如何从 wordpress 中删除 "Category: [category name]"

wordpress - 使用 cron 作业运行 wp cli 命令

php - 在页面加载时从一个页面转发到另一个页面时在网页中显示警报消息

wordpress - 如何在 Visual Composer 'custom_markup' 中使用 'vc_map' 参数?

javascript - Google Recaptcha(联系人仍然发送通过)

wordpress - 在 WordPress 中使用 CMB2 添加具有自定义回调函数的自定义元框?

mysql - SQL : Update column (username) with content from another column in same table (email address)

php - 在 jQuery 中设置?

php - 避免在 PHP 中执行部分变量