Query_posts alters wp_list_pages output
-
I have a static front page on which I’m using query_posts to list the latest post:
<?php if (is_front_page()) query_posts('showposts=1'); ?>
All of my site is designed with two navigation bars – one at the top of the page, which comes before The Loop, and another at the bottom of the page, which comes after The Loop. They’re both called in the same way:
wp_list_pages('title_li=&sort_column=menu_order');
The problem is that their output is different on the front page. The one at the top works correctly – it adds “current_page_item” to the current page
- . But the one on the bottom does not. Instead, it adds “current_page_parent” to the BLOG page
- . For other pages, everything works correctly.
I’ve narrowed the problem down to query_posts actually changing the type of the page that it’s called on, e.g. putting the following on the front page:
<?php if (is_front_page()) echo 'Test 1'; ?> <?php if (is_front_page()) query_posts('showposts=1'); ?> <?php if (is_front_page()) echo 'Test 2'; ?>
…will print out “Test 1”, but not “Test 2”. Why is that? What can I do to keep query_posts from changing my page type? Or is there a workaround to calling query_posts to get the latest post on my static front page?
Thanks!
- The topic ‘Query_posts alters wp_list_pages output’ is closed to new replies.