Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#12647 closed defect (bug) (worksforme)

$wp_query doesn't report the full pagename for nested pages

Reported by: dphiffer Owned by: ryan
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:


I've just discovered a bug in my JSON API plugin where it is unable to introspect on sub-pages. Instead of getting the page's data in JSON format (as you do for pages at the root level), the API returns the same response as if you had requested a non-existent page. Consider the following:

$pagename = get_query_var('pagename');

If you run that code against a path like "/page/subpage/" you will get a 404. In this case the value of $pagename from the first line is going to be 'subpage', but the query_posts pagename parameter is expecting a full path like 'page/subpage'.

Change History (4)

#1 @dphiffer
11 years ago

  • Summary changed from $wp_query doesn't report the full pagename to $wp_query doesn't report the full pagename for nested pages

#2 @nacin
11 years ago

  • Component changed from General to Query
  • Milestone changed from Unassigned to Future Release
  • Owner set to ryan

This is how WP_Query is written. It overrides pagename (full path) with just the page name itself.

Perhaps we should store the original full path in another var, or allow pagename to take optionally the page name only, not requiring the full path. Not sure how doable the latter is.

#3 @dphiffer
11 years ago

  • Cc dphiffer added

#4 @wonderboymusic
9 years ago

  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from new to closed

In the past 3 years, this appears to have been fixed

Note: See TracTickets for help on using tickets.