开发者

show sub-subpage on wordpress homepage

开发者 https://www.devze.com 2023-02-13 14:02 出处:网络
Let\'s say we have the following menu structure: menu #1 menu #2 menu #3 - submenu #1 -- subsubmenu #1 -- subsubmenu #2

Let's say we have the following menu structure:

menu #1

menu #2

menu #3

- submenu #1

-- subsubmenu #1

-- subsubmenu #2

-- subsubmenu #3

- submenu #2

- submenu #3

menu #4

menu #5

In WordPress how can i show up on the landing/homepage (index.php hard coded) the content of the #subsubmenu #2 and #subsubmenu #3 which suppose are the last two added subsubpages under the #submenu #1 page?

I followed the suggestions by the next page:

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

I used the next code:

<?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>开发者_StackOverflow中文版;<?php the_excerpt(); ?></p>
                </div>
                <?php endwhile; else : ?>
                <?php endif; ?>
                <?php wp_reset_query(); ?>

No success. Any suggestions?


You can use the order by menu_order parameter for your query, and having a descending order to sort it out.

Note: you must use the menu_order attribute under the Page Attribute Box, at the right of the edit screen

Rewrite your query as

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

See: http://codex.wordpress.org/Function_Reference/query_posts#Order_.26_Orderby_Parameters

0

精彩评论

暂无评论...
验证码 换一张
取 消