WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 18 months 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:

Description

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');
query_posts("pagename=$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)

comment:1 dphiffer4 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

comment:2 nacin4 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.

comment:3 dphiffer4 years ago

  • Cc dphiffer added

comment:4 wonderboymusic18 months 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.