Php Wordpress显示页面内容和循环?
我在页面模板中有一个自定义循环,可以按类别和标签显示文章。它可以工作,但在循环上方,我需要显示页面本身的内容,即通常输入Wordpress仪表板的内容 我应该向模板中添加什么来显示此内容 我试过:Php Wordpress显示页面内容和循环?,php,wordpress-theming,wordpress,Php,Wordpress Theming,Wordpress,我在页面模板中有一个自定义循环,可以按类别和标签显示文章。它可以工作,但在循环上方,我需要显示页面本身的内容,即通常输入Wordpress仪表板的内容 我应该向模板中添加什么来显示此内容 我试过: $id = $post->ID; get_page($id); // then my custom loop 它确实获取当前页面ID,但没有内容 使用内容()功能显示页面内容 在此函数调用后添加了自定义循环。在WordPress中,调用 <?php the_content(); ?
$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 -->
这里有更多信息:在我的例子中,有一个现代的主题和使用古腾堡块,我必须在帖子循环之前对内容应用过滤器,如本文所述:
以下是一个简单的工作解决方案:
<?php
$id = 669; // page ID that has been assigned for posts
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
<!-- Enter your custom loop for displaying posts by category down here -->
谢谢,我不知道我可以有多个循环!这个解决方案在这个年龄和时间将不再有效。