I have solved the answer to this problem by doing this:
echo get_permalink( $page->ID );
This gave me the right links to the pages.
Related Posts:
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Nested custom post types with permalinks
- How To Limit Hierarchical Pages Depth (For Custom Post Types) To Children Only
- Display a list of child posts on parent posts of a custom post type
- 404 on child page when parent page slug is identical to custom post type
- How to handle a hierarchy with custom post types
- Hierachical Custom post types permalinks not working
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- How to check if last uri segment is a custom post type or taxonomy term?
- Custom permalinks – post type – hierarchical taxonomy’s
- Custom Taxonomies: Multiple Hierarchical Permailnks For A Single Post + Prev/Next Links
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Share parent path between Custom Post Types and Pages?
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Custom rewrite rule for hierarchical custom post type
- Child post with numeric only slug keeps redirecting to parent
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- How to set a CPT to have a page as a parent, then rewrite urls accordingly?
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Need help with permalink rewrites for Custom Post Types with hierarchical relationships
- Hierarchical permalinks for custom post type and taxonomy
- Custom post type Permalinks with hierarchical Taxonomies
- Ideas on how to organize a project [closed]
- Permalink with hierarchy of Custom Post Types
- Standard Page Child of CPT Not Found (404)
- hierarchical Custom post type child permalink not found
- How can I add a “fake” parent into the permalink?
- Custom post type child page 404
- taxonomy term names in custom post type permalink structure
- Custom Post Type Child Pages
- Cross post type parent page added parent page to permalink but give 404
- Permalink Structure for Multiple Post Type Archives by Taxonomy
- Taxonomy, Terms, and Template Files
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Adding meta values to permalink
- Custom Posttype Inheritance (and url structure)
- Can you have two CPTs with the same permalink structure?
- Custom taxonomy & post slug permalink
- Display posts of custom type in hierarchical order
- how to use two permalinks for one custom post type
- Custom Taxonomy List links being re-written
- Query in a Hierarchical Custom Post Type for Children vs Siblings
- Detect if 1st, 2nd or 3rd level custom page?
- Custom Permalink Tag breaks Pagination
- Custom post type routing with hierarchy
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- Extend the wp_get_archives output with ‘?post_type=foo’?
- Function to get permalink of custom post type archives?
- How do I prefix blog post urls as mysite.com/blog/%postname%/ but allow authors to still be located at mysite.com/authors/%nicename%?
- Automaticly add slug to posts
- Different permalink for CPT and regular Posts/Pages but why?
- Custom post type, permalinks & pagination, going wrong
- Custom post type template and custom post page not working
- Bizarre Permalinks Issue: 404 Errors Everywhere
- post_row_actions not working for hierarchical post type
- Making a custom help center page
- Custom Post Type / Two level deep taxonomy (cat. and subcat.) uri problem (error 404)
- WordPress Custom Post Type Repeated 404 Errors
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- Next and Previous Posts of Same Parent
- WordPress custom post type permalink rewrite shows page not found
- Removing custom post type slug from URL
- Customize Custom Post Type URL
- Remove CPT name from permalink but add %category% instead
- How to have this permalink structure: post_type/postname/custom_inner_page
- What code should I use to display children of a custom post?
- “Post name” permalink returns home page for custom posts
- How to make permalink structure %category%/%postname%/ work for custom post type?
- Rewrite rule for Custom post type Monthly and Yearly archive
- menu link to custom post_type?
- Custom permalink with child taxonomy terms
- How do you create %post_type%/%postname%/ permalink structure?
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- Can variables be used to rewrite a Custom Post Type permalink? [duplicate]
- Set parent for custom post type archive rewrite url
- How to rewrite the beginning and end of the permalink structure in a custom post type?
- custom hierarchical taxonomy and custom post type list contains surplus posts
- Custom Post Type Archive template not being called
- How to setup a permalink structure for a custom post type
- add_query_arg() for custom post type on all visible links
- WordPress custom posts and permalinks
- Custom post type, permalink, add query variables problem
- CPT permalinks Rewrite
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Custom taxonomy terms hierarchical navigation
- CPT relations use in permalinks under single post type
- Custom Post Type Single Page and Archive Page redirects to Home Page
- How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]
- Allow duplicate permalinks slugs for custom posts by different authors
- Creating custom post type relationships
- Change wordpress url permalink structure to show authors posts
- Custom Post type and Taxonomy in post URL error
- Custom Post Type + Category archive
- Multiple Custom Post Type permalink issue
- Custom Post Types and rewrite rules – One CPT works and a cloned one doesn’t
- How to retrieve the permalink for a specific (custom) term?
- General question about Parent and Child Post type relationships
- How can you preserve URLs when moving posts to a custom post type?
- Rewriting hierarchical post type
- 404 Error On Custom Taxonomy Pages 2, 3, etc