0

制作单页 Wordpress 主题。使用此循环调用所有页面并将它们显示为部分(html5 标记):

<?php
$args = array(
    'post_type' => array( 'page' ),
    'post_status' => array( 'publish' ),
    'orderby' => 'menu_order',
    'order' => 'asc'
);
query_posts( $args );

if (have_posts()) : while (have_posts()) : the_post();?>
    <section id="<?php echo $post->post_name; ?>" class="<?php echo $post->post_name; ?>">
        <div class="inner clearfix">
            <?php the_content(__('(more...)')); ?>
        </div>
    </section> 
<?php endwhile; else: ?>
    <p>Sorry, no pages matched your criteria.</p>
<?php endif; ?>

这会基于页面创建一个不错的小部分循环。我唯一担心的是:这些“页面”/部分之一应该显示一些博客文章。寻找一种在循环中创建循环的方法——可以与页面一起重新排序。

所以我想我的问题是:

  • 这段代码可能是什么样子?
  • 将这段代码放在 wordpress 页面编辑器中的文本编辑器中是完全错误的吗?这似乎是错误的,但我想不出其他方法。

谢谢!

4

1 回答 1

0

WordPress has this functionality built-in. See documentation.

于 2020-07-29T04:02:48.893 回答