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?
- Get current menu_order
- ORDER BY custom field value
- Sorting: custom query with orderby meta_value_num THEN by title
- Custom Table Column Sortable by Taxonomy Query
- How to get order of posts?
- Order posts by meta_value even if meta_key is not filled
- How can I custom order the results from wp_list_categories?
- 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]
- Sorting by tag or category
- Customize the Sorting Dropdown in WooCommerce
- 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
- 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
- How to get_posts where ‘menu_order’ is more than 0/zero?
- How to set multiple `orderby` in query argument?
- Sort posts by meta key that is serialised with other meta keys
- Sort query_posts for Parent Pages to menue order or the count?
- 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?
- How to sort posts inside categories
- Help ordering Post loop by two meta values
- Trying to sort and display categories(not posts) by custom field: ‘order’
- Custom taxonomy/category order
- wp e-commerce group product by category [closed]
- How do I create a sort capability by Title, Category, Author, Date?
- 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
- 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 items by randomness
- inner foreach loop sorting
- How to manage a particular “order by” for get_search_query()?
- Sort appearence order in the_content()
- ASC and DESC separately from orderby
- Sort my event calendar by date
- orderby ignored by wp_query
- Sort products by Sale price and stock status
- How to sort store location by specific category order in WP store locations
- Order column custom date using pre_get_posts
- How to display remaining post ( in post__in ) if posts are less then post per page?
- How to sort wordpress posts already selected by WP_QUERY
- How to sort products by price ASC and place all no price products to the end? (Woocommerce)
- sort title descending with title with number
- Custom post type order by post_title
- Order by value of Custom Field using url string
- WP Query with meta queries
- Sorting in WP_List_Table class
- Wp Query sort order from custom MetaBox
- Orderby Title not working
- Multiple sorting criteries (order by)
- Using Orderby and meta_value to order natural/alphanumerical
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Sort an array with an ACF meta key
- How to sort custom post’s category by id from the theme’s function.php?
- Display three sequential posts on each page load, without repeating previous
- Best way to sort posts with different types by distance
- display wordpress user who published a pending post of another user
- Custome column sort by date not title
- How to order posts by the user_login that corresponds to a meta_value (which is a user id)?
- Query category-specific, paginated posts and allow viewer to change sort order
- query_posts with sorting on a custom datestamp
- How do I sort post listing by child post count?
- Getshopped (WP-e-commerce): show all protucts on one admin page for drag-and-drop ordering [closed]
- Echo order box (in pages)
- Multidimensional array sort?
- How can users sort multiple pages?
- category & sub category order issues in wordpress
- Sort wordpress posts by facebook likes [closed]
- How to resort my id in wordpress?
- Ascending & descending posts on same page with IF statement
- How can I set the default ‘orderby’ and ‘order’ parameters for a REST API call?
- How to sort posts alphabetically based on a specific parent category