Timeline for WP_Query post_parent parameter always returns children of current page
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
S Nov 3, 2014 at 17:54 | history | suggested | sba222 | CC BY-SA 3.0 |
Included solution from discussion below
|
Nov 3, 2014 at 17:53 | review | Suggested edits | |||
S Nov 3, 2014 at 17:54 | |||||
Nov 3, 2014 at 17:49 | vote | accept | sba222 | ||
Nov 3, 2014 at 17:48 | comment | added | Pieter Goosen | Great. I hope this pans out for you. Enjoy :-) | |
Nov 3, 2014 at 17:45 | comment | added | sba222 |
No pre_get_posts instances. But I think I just found the solution: Polylang creates a new custom parameter "lang". This parameter appears to default to "", which is supposed to return posts with any value. Instead it returns posts with the current page's language value only (hence only children of current page ID = 5). As a fix I now manually loop through the available values for "lang" to get pages with all values for "lang". I'll check with the plugin author if this is a bug or caused by my environment.
|
|
Nov 3, 2014 at 17:39 | comment | added | Pieter Goosen | What seems to be the cause | |
Nov 3, 2014 at 17:26 | comment | added | Pieter Goosen |
Do you have any instance of pre_get_posts somewhere. Also, have cleared all caches and have you tried switching to a bundled theme. Post the complete page template. You can just remove any markup
|
|
Nov 3, 2014 at 17:23 | comment | added | sba222 |
This is on a plain-ish template and page but I just realized that the issue goes away when I deactivate the polylang plugin! wp_reset_query() before the query does not help. Is there a way to safeguard the WP_Query from being messed with after the parameters have been set? I don't understand how at this point polylang (or anything else for that matter) can interfere with the query?!
|
|
Nov 3, 2014 at 16:55 | comment | added | Pieter Goosen |
Sorry, misread your question. Where exactly, on which template, are you using this. Is this on a page.php template. Are all custom queries reset. Try to add wp_reset_query() before your query
|
|
Nov 3, 2014 at 16:38 | comment | added | sba222 | Thanks for digging in! I do want to get the child pages. First of page 5, then of 128, then of 130. My parameters going into the query correctly, but the query seems to reset the post_parent parameter to the current page's ID. | |
Nov 3, 2014 at 16:09 | history | answered | Pieter Goosen | CC BY-SA 3.0 |