You can use wp_list_pages()
instead. Just pass your post type in if you’re trying to list something other than Page-pages:
<ul>
<?php wp_list_pages(array(
'post_type' => 'yourposttype',
'title_li' => ''
) ); ?>
</ul>
If you wanted to display this on all post types you could use
<ul>
<?php wp_list_pages(array(
'post_type' => $post->post_type,
'title_li' => ''
) ); ?>
</ul>
which would automatically grab the post type of the currently viewed item and display the full tree for that post type.
Related Posts:
- Software for WordPress Theme and Plugin Development? [closed]
- How to detect mobile devices and present them a specific theme?
- Using wp_add_inline_style without a stylesheet
- How to override pluggable function in theme?
- Should we use get_template_part() in functions files instead of include_once?
- Reset positions of metaboxes in admin
- Remove the word ‘Categories’ from wp_list_categories
- Using Bootstrap in themes
- Add a dropdown to theme customizer
- design and development workflow
- How to control initial wp_head() output?
- enqueue script for specific shortcode
- The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme
- Any walker causes blank menu?
- How can I insert default widgets when my theme is activated (similar to what twenty eleven does)?
- How to change post thumbnail title and alt attributes to post title?
- Why might $input (Settings API) be coming through empty?
- add generated stylesheet from parent theme after child-themes style.css
- date_i18n() issue
- Creating Page Based on Category
- How to check if post has any tag?
- using wp_enqueue_script to attach jquery-ui
- Merging PHP download script into `functions.php`
- Should use widgets in this case?
- Changing the entire control choices using wp.customize with JavaScript
- Static Front Page problem
- Can not Remove Archives and Meta from Sidebar
- Get last modified date for menu link
- A theme that follows all the best practices to learn from?
- get_post() function returns post even if it is trashed
- WordPress how to override function adjacent_posts_rel_link_wp_head() in link-template.php the correct way
- Can wordpress run in root of existing php site with no theme on index.php but all other WP posts/pages?
- How to regenerate thumbnails when they’re stored on S3
- Change file name from wp_generate_attachment_metadata
- Change setting name in Customizer and keep the data
- CSS won’t style output of wp_nav_menu() correctly
- Creating multiple hooks for theme
- after_setup_theme, Global Variable and Theme Customizer
- How to make WP admin recognize a newly created child theme?
- Can’t show custom post thumbnail sizes as background images
- Theme translation not applying
- How to add filter the post thumbnail before save in database?
- Custom theme development additional pages
- How to add material design css in wordpress and woocommerce
- How to set the currently active page in the menu including parents
- changing blog title to an image using filter function in child theme
- What is the safe way to print tracking code / pixel code before tag or tag
- WordPress taxonomy and archive custom class
- Acivate all themes multisite wide automatically
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
- How to remove text “Log In” from login page
- Website pagespeed problem
- Theme support title tag – how to replace the default WP separator (with a filter)?
- Why are some of my menu items not displaying on my menu?
- Managing WordPress Theme
- ajax response -1 in wordpress theme
- next_posts_link and previous_posts_link problem
- How to change footer credit text in Twenty Twenty One theme with a hook?
- Data Validation in wordpress
- Gutenberg theme development: how to add “headers” option under styles > colors > elements?
- Localize script not working in ajax
- How to override template files in parent theme?
- Want to add cart and a search bar in the right of logo line
- Output richtext metabox value
- Twenty Twelve Author not displaying
- Default PHP document / names needed for a WordPress theme?
- Custom fields for custom post types
- How can I sort my loop based on meta data, using a form?
- What is the_permalink() on a category page?
- How to modify theme content in Thematic?
- How to determine when my theme is deactivated?
- 1 post per category on homepage and counting those posts
- WordPress theme options checkbox default checked state
- Custom themes that won’t work when theme is changed
- only the first post is shown
- wordpress can’t find single-project page
- WordPress Theme: What is the right way to put inline CSS loading from a CSS file
- Is there a way to add classes to a page when using a Gutenberg reusable block as page layout?
- Cold Fusion to WordPress
- How to show some of category in wordpress
- How to make the media library searchable by image title
- How do I build a WordPress Profile/Author Header?
- Custom page template not showing on page creation
- Create settings field on button click
- get_posts is duplicating
- Undefined index: custom_sidebars
- How To Customise WordPress Comment Submit Button?
- Next/Previous post navigation
- Single Featured Image Repeating
- How to remove menu from WP-Admin menu
- apply_filters to featured image
- How do I move menu to the bottom in Custom Community theme?
- How do I get information about a page, such as featured image, except, and title?
- A problem in loading index.php
- .submenu class missing in output from wp_nav_menu
- Is there a way to have WordPress autodetect page templates in the page-templates directory and any sub-folders?
- Feeds are showing where Post archive page should be
- WordPress Two Level Filters on Getting Custom Taxonomy Terms
- I want to resize post featured image without cropping image. How?