首页 文章

Wordpress显示页面内容和循环?

提问于
浏览
1

我在页面模板中有一个自定义循环,通过类别和标记按类别显示帖子 . 它可以工作,但在循环之上我需要显示页面本身的内容,即通常输入到Wordpress仪表板的内容 .

我应该在模板中添加什么来显示此内容?

我试过了:

$id = $post->ID;
 get_page($id);
 // then my custom loop

哪个获取当前页面ID,但没有内容 .

2 回答

  • 5

    在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

  • 1

    要使用 the_content() 功能显示页面内容 .

    在此函数调用后添加了自定义循环 .

相关问题