The problem with grasping implementation for such deeply nested tree is that it is best solved recursively – your code should output post, then output children and endlessly repeat the process for each child until it runs out.
However before you spend time on custom implementation you could try to look into existing functions WP provides. For example wp_list_pages()
can really be used for arbitrary post type and should handle hierarchical output for you.
Related Posts:
- Ascending sort order for monthly & category view, i.e. ?m=201204, ?cat=4
- get_terms orderby name as numbers
- Displaying posts sorting by a custom criterion
- Orderby menu_order not working; menu is sorted on publish date
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- How to Change Order of Posts in Admin?
- Get current menu_order
- visually sort ordering “custom post types” for end users
- ORDER BY custom field value
- Sorting: custom query with orderby meta_value_num THEN by title
- Different post sort order within different categories
- Custom Table Column Sortable by Taxonomy Query
- How to get order of posts?
- How to order users alphabetically by their last name?
- Sort posts by tags in category pages
- Order posts by meta_value even if meta_key is not filled
- How do I order pages and categories by ID or name in the same query?
- How do I allow users to sort posts? [duplicate]
- How to sort posts by last name (2nd word) on ONE category only?
- Sorting results from JSON-API on custom fields
- How can I custom order the results from wp_list_categories?
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Sort users in get_users() in custom order
- Custom Post type sort order not working in the admin area
- How can I set a default listing order on the admin page for a custom taxonomy? (without plugins)
- Sort by custom field value
- How to sort posts with the first 2 or 3 by latest, and the rest is random?
- Get “wp_get_nav_menu_items” to sort alphabetically [duplicate]
- Adding Sorting to Website?
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- Sorting by tag or category
- Customize the Sorting Dropdown in WooCommerce
- Orderby Post Views
- Creating a category page by alphabet
- Arrange and separate posts
- Sorting posts by multiple values, combined
- Meta query with order by another custom field
- Change default ordering of taxonomy terms – pre_get_terms
- Sorting get_post_ancestors array
- wordpress custom_meta ordering of timestamps
- Multi-level ordering in WordPress
- Sorting for custom column in WordPress admin post table
- Help alphabetically sorting $terms from get terms(‘wpsc_product_category’
- How do I sort posts with multiple pages
- Vertical alphabetically post columns
- orderby:date not working
- Advanced custom fields sort repeater by date
- Ordering of gallery images without using shortcode in theme
- Combining sorted and random CPT
- Order wordpress taxonomy parent terms by their children count
- How to get_posts where ‘menu_order’ is more than 0/zero?
- Use pre_get_posts to sort meta_key by an array of values
- How to set multiple `orderby` in query argument?
- Sorting custom post type by usermeta
- Wp_query: sort by PHP variable
- Sort posts by meta key that is serialised with other meta keys
- Sort query_posts for Parent Pages to menue order or the count?
- orderby field – list of available options?
- Show Primary Category first when I display post categories
- How to redefine the sorting of product categories by menu_order?
- Sort CPT archive by order prevents sorting in admin
- User Query sort on custom field then name
- Sort wordpress custom posts based on meta value
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Understanding the orderby in WP_Query?
- I Changed the Menu Order, But the Page Order Didn’t Change on Front Page
- Sort order by slug for looped child terms of custom taxonomy
- WP Query sort by meta value
- How to sort posts inside categories
- Help ordering Post loop by two meta values
- Best Practices for a Completely Customizable Homepage – without plugins
- Trying to sort and display categories(not posts) by custom field: ‘order’
- Custom taxonomy/category order
- Sorting posts by custom field value
- wp e-commerce group product by category [closed]
- How do I create a sort capability by Title, Category, Author, Date?
- how to get post order by post id wp_query?
- How to avoid duplicating same meta_value?
- Sorting/Filter posts from front-end in WordPress blog
- ‘sort_column’ => ‘menu_order’ not working
- Custom post type sorting: alphabetical order
- ORDER BY custom field value out of where clause
- I would like my page editor to be sorted by date created, or updated, instead of in Alpha order, is this possible?
- Sort custom posts in archive by multiple values: date AND meta key
- Sort scheduled posts in ascending order by default
- How to sort by number
- sort items by randomness
- inner foreach loop sorting
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- Sortby parameter to sort users
- Update meta_key value for a page
- How to manage a particular “order by” for get_search_query()?
- Sort appearence order in the_content()
- Natural sort / ordering wp_dropdown_categories
- ASC and DESC separately from orderby
- Sort my event calendar by date
- orderby ignored by wp_query
- Sort users by meta key value even if meta key not present for all users
- Table Sorter sort by span title?
- Sort products by Sale price and stock status