Another get_pages() question
-
Okay, I’m back with one more question about getting child pages with get_pages().
What I’m attempting to do is look at the current page’s child pages, if it has a child page with a specific taxonomy term, show the child instead of the parent.
I’ve got this working almost 100% of the time, however, I just ran into a weird problem with the home page.
Here’s how I’ve got the pages set up
- Home (set to Front Page)
- Alt Home Page*
- About Us
- Mission
- Alt Mission Page*
- History
- Alt History Page*
The get_pages code I’m using is this (you can see the rest of the code here):
$args = array( 'child_of' => $pid, 'hierarchical' => 0, ); $children = get_pages($args);
This setup is giving me exactly what I want on every page except for the home page. On the Mission page, I get the Alt Mission page (and other children of Mission page) in a list, check for the taxonomy term, and then shows the one with the taxonomy term (the Alt Mission page).
On the home page, I get a list of all pages **including the home page itself** (because apparently WordPress sees them all as children of the home page), so when I search for the taxonomy term, it finds every page with this taxonomy term and then shows the content for (I’m assuming here) the last one it finds: the Alt History Page. If I add
'parent' => $pid
, only top level pages are returned.So, my question is: How can I get only direct descendants of the Home page? Do I need to check is_front_page() and handle the Home page differently (provide a specific ID to use)?
Any help would be much appreciated.
- The topic ‘Another get_pages() question’ is closed to new replies.