Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#12169 closed defect (bug) (worksforme)

query_posts returns invalid page data under specific circumstance

Reported by: layotte's profile layotte Owned by: ryan's profile ryan
Milestone: Priority: normal
Severity: normal Version: 2.9.1
Component: Query Keywords: reporter-feedback
Focuses: Cc:

Description

If you use query_post to query for a page that is being used as the "Post Page" it will return invalid results.

My test environment has these pages:
About => id.2
Contact => id.19 (set as Front Page)
Latest News => id.20 (set as Post Page)
Store=> id.21

query_posts("showposts=1&page_id=20&post_type=page");
OR
query_posts("showposts=1&pagename=latest-news&post_type=page");

Will give me the page info for "Store". If I use this:

query_posts("showposts=2&page_id=20,2&post_type=page");

It will give me the page info for "Store" and "Latest News" (it should give me results for "Latest News" and "About").

In wp-includes/classes.php lines 1444-1464, $this->is_page is set to false when the page is also the page_for_posts. I assume this is related to the problem, but it doesn't exactly explain why it would return a different page altogether.

Change History (4)

#1 @scribu
15 years ago

  • Component changed from General to Query
  • Owner set to ryan

#2 @nacin
15 years ago

As far as I know, this is by design. A page for posts is a unique situation and it isn't treated like a regular page in many aspects.

#3 @nacin
14 years ago

  • Keywords dev-feedback added; query_posts page_for_posts removed

it doesn't exactly explain why it would return a different page altogether.

No, it doesn't.

#4 @nacin
14 years ago

  • Keywords reporter-feedback added; dev-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Going with being caused by a plugin. Feel free to reopen with more info.

Note: See TracTickets for help on using tickets.