在wordpress主页上显示子页面

时间:2011-02-27 18:40:58

标签: php wordpress

假设我们有以下菜单结构:

菜单#1
菜单#2
菜单#3
- 子菜单#1
- 子菜单#1
- 子菜单#2
- 子菜单#3
- 子菜单#2
- 子菜单#3
菜单#4
菜单#5

在WordPress中,我如何在登陆/主页(index.php硬编码)上显示 #subsubmenu#2 #subsubmenu#3 的内容假设是 #submenu#1 页面下最后两个添加的子页面?

我按照下一页的建议进行了操作:

http://codex.wordpress.org/Function_Reference/query_posts

我使用了下一个代码:

<?php query_posts('post_parent=12&posts_per_page=2'); ?>
                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
                <div class="entry">
                    <p><?php the_excerpt(); ?></p>
                </div>
                <?php endwhile; else : ?>
                <?php endif; ?>
                <?php wp_reset_query(); ?>

没有成功。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您可以使用menu_order参数的顺序查询,并按降序排序。

注意:您必须使用编辑屏幕右侧的页面属性框下的menu_order属性

将您的查询重写为

<?php query_posts('post_parent=12&posts_per_page=2&orderby=menu_order&order=DESC'); ?>

请参阅:http://codex.wordpress.org/Function_Reference/query_posts#Order_.26_Orderby_Parameters

相关问题