please add your Custom post type name here ‘post_type’ => ‘Services’, // required
<?php
$args=array(
'post_parent' => 0, // required
'post_type' => 'Services', // required
'orderby' => 'menu_order', // to display according to hierarchy
'order' => 'ASC', // to display according to hierarchy
'posts_per_page' => -1, // to display all because default is 10
);
$query = null;
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while($query->have_posts()) {
$query->the_post();
$post_id=get_the_ID();
$post=get_post($post_id,'ARRAY_A');
echo $post['ID'].': '.$post['post_title'].'<br>';
}
}
wp_reset_query($query);
?>
Related Posts:
- Only looping through pages that have children or subpages
- Display all posts in a custom post type, grouped by a custom taxonomy
- How to use a custom post type as front page?
- Retrieving 3 latest post from each of 5 different custom post types
- Newer/Older posts links display same posts on every page
- How to solve suspected memory issue in custom WordPress loop?
- Problems excluding a custom post-type from the loop
- Displaying custom posts only if custom meta box’s date is not expired
- Integrating Orbit slider into wordpress through custom post type
- Custom Post Type not visible on category page
- Loop on front-page.php
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- WP_Query | ‘post_type’ doesn’t work
- Filter by custom taxonomy slug on a custom post type
- Creating Multiple Loops in Genesis, One Post then 20, each with custom fields
- Loop through Custom Post Type, and then show children within each iteration
- Change or update WordPress loop based on dropdown selection
- Can I create a loop with multiple post types and specify different $args for each post type?
- Am unable to reset a query properly
- How to make sure content doesn’t display if selection is empty
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How to display all posts from standard posts to custom post types in a loop with pagination?
- Get next and previous 3 posts in a term in single post page
- Best way to style first post differently?
- Shortcode not working with post counter
- Get custom post type’s fields in a while loop as variables
- Posts per row on archive page (custom post type)
- pagination not working for category.php (custom post types in categories)
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- How do I control the output of a custom post type in the loop?
- WordPress Loop if/else
- WP Query post__in not returning correct results
- Custom Post Type single.php template only shows the latest post
- Tag page only display 10 posts
- Pagination Error : Duplicate argument being outputted
- get_post_type is always post
- Custon Content within WordPress Loop
- get_post_meta is not working inside shortcode
- Create Array from custom post type to display a slider
- get_pagination not working on a custom post type query (using WP_Query)
- How to Make infinite loop of post
- WP_Query with custom post type ID
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- postsperpage value not being applied
- How do I display child post types in the parent post type template
- Display the current post in browser as the first post in a loop (for a slideshow)
- Multiple Loops on a Page Without Duplicates
- Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis
- Loop Post Types with Name and Links
- Display all images from specific CPT
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- Custom post type hierarchical loop in Homepage
- Use Author Ids or Names to echo different output inside loop
- Custom Post Type, Pagination and 404s?
- What is the most efficient way to execute recursive complex queries?
- Last post in loop – custom post types
- Display category name of custom posts only once in the loop
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- CPT loop doesn’t seem to account for post date?
- How to display list of custom post taxonomy terms and their posts (if any)?
- Make bootstrap 5.0 carousel dynamic using ACF and CPT UI [closed]
- check if current page is a child of a specified top level page
- Pagination Not Working When Used With WP_Query() `offset` Property
- Excluded Custom Taxonomy Term Posts Displaying in loop
- Display all posts from specific category and CPT
- posts_per_page is not working by term
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- subtracting the current post form then whole loop, which is generating all CPT titles
- % encoded URL giving 404 error in WordPress
- CPT: multiple loops with different terms
- Can I show some specific post rather than latest post?
- Custom post Query and WordPress Post Query Clash
- Add active class to foundation 6 tabs while looping categories
- Infinite scroll doesnt work
- Excluding category from loop not working
- How to return custom posts in loop?
- custom post type loop
- Custom taxonomy page template
- Loop with Custom Post Type and Taxonomies
- WordPress Custom Post Type and sort by Tags
- After rewriting post type’s URL, the number of queries has increased dramatically
- Display posts from category in page
- Multiple Queries and Loops within CPT Archive
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Custom Post Type children and grand-children in one list
- Sorting custom post types by taxonomy (So close)
- Pagination not working with custom loop
- Pagination not working with custom loop
- Looping taxonomy in taxonomy?
- Custom Post Type Loop breaking php
- Styling first post using Advanced Custom Fields
- Query Custom Post Type by Tag
- Loops running into each other
- Display by tag from different post types
- Loop doesn’t work in single-product.php page but works at normal page
- How do I filter a custom post type loop by a field?
- Allowing null vairiable
- WPNavi pagination links not working on custom pages
- Where paramaters of a custom function are coming from inside the loop?
- Group search results by post type, but having a unique heading for each section?