I'm trying to create a page template that outputs the page content first, and then links to the subpages of that page. I can't use
wp_list_pages() though, because I need to use some custom fields from those subpages.
So I get those pages with a custom SELECT query directly from the database and create a second loop after the first one, as per these instructions on the Codex.
The problem is this: inside the second loop, template tags like
the_permalink() still output their values for the parent page, instead of the subpage the loop is working on at that point. Things like
the_ID() do contain the right values however.
Does anyone have any idea why this is, and how I can fix or work around it?
Or is there perhaps an easier way to to this that I'm not aware of?
Thanks in advance.