There is a parameter in WP_Query called post_parent. Normally this refers to the ID of the post’s parent, but since its an integer field, pages without a parent have in essence a post_parent of 0.
So, to get all pages that are not child pages of another page, you could use
query_posts( 'post_type=page&post_parent=0' );
or, in array syntax that would be
query_posts( array(
'post_type' => 'page',
'post_parent' => 0 ) );
Related Posts:
- Getting only direct child pages in WordPress with get_pages
- Display child page content of a specific parent on home page
- How to add a .php file to WordPress
- Get only the grandchildren, not the direct children of page/current page?
- Help with a custom page template – listing contents of childpages?
- Easiest way to show total number of subpages
- Custom Template 404 for specific custom post type
- Page Automatically Generated from Theme?
- Populate editor with some content of a page with a page template
- How do I Turn This Into An if statement?
- get_the_title() gets printed out twice
- Inject class in body when particular page template is used
- page-slug.php not working but only for specific slug
- Posts are not looping through correctly
- List all anchor links on a page
- How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
- Display page content in different sections – based on page break block?
- Child and Parent Pages list of sub pages
- Get current_post in reverse order with pagination
- Create a custom theme-specific page, invisible in the admin-panel?
- List of child pages fetch next results at link click
- Execute php in pages
- Why isn’t my link attribute getting my css?
- How can I put a custom field as the link of a button shortcode?
- Tables not showing divs and loop/php items
- How to handle parent and child pages?
- Loop on a wordpress Page instead of content coming from the WP text editor
- How do I remove blog entries from home page Twenty Eleven child theme?
- WordPress post-template null warnings
- Custom theme on multisite has issues with standard loop output
- Query multiple custom post types in single loop
- Inject post (from specific category) between posts in Loop
- Knowing the total number of posts before to get into the loop
- Child Pages Loop
- Build a content and excerpt grid loop with paging and options for # of posts
- WordPress admin never finishes saving page on site with large page count
- How to loop over custom fields in a page template?
- Want to separate sections of posts. Can you restart loop?
- Alter secondary loop to exclude posts from current page category
- Two posts in same div – WP loop
- Listing all sub-pages?
- How can the plugin directory path be returned into ?
- How to speed up a wordpress function with multiple loops?
- syntax issue on php 7.4
- $wpdb->flush(); breaks the loop
- Use object in template part
- Get first URL from post content
- Global variable $post returning incorrect object
- How do I list the child of a child page [duplicate]
- Show css depending on activity type in BuddyPress activity-loop [closed]
- My page.php shows the index.php
- remove post that has no content
- Checking array against author id in loop
- Use .php file as page instead of wordpress page & template file?
- Adding wrapper elements in the_date() like in the_title()?
- How to check if the current page is at a specified path in the URL?
- Echo a shortcode div after every 3 posts
- How to avoid duplicates when creating recent network posts
- Editing a PHP file to include a small text piece on every page
- variable value disappears in a second loop
- Need php code’s output to display underneath a Divi Module
- Why my loop isn’t working? [closed]
- Get all posts as an array ID => Name
- How to get post ID from button and pass title to Modal
- Do not duplicate posts with multiple categories in multiple loops
- How to wrap every 3 posts in a div (and close the last div too) [closed]
- Dividing the loop to style post differently
- How to Display a List of Child Pages For a Parent Page in WordPress
- If is page, archive or search output this code
- WordPress Search
- WordPress loop is not working
- Page load timer?
- Static Website No Titles But Still Nav
- Problem in replacing the_content with the_excerpt()
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- Edit and delete permissions pages and posts
- Pagination contents not changing in Front page WordPress
- Display all categories including sub categories under a list ul
- Where does php code to load data go?
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Latest posts feed with a specific post always first
- How to output values from a loop into a javascript array
- can’t grab PHP $_POST variable
- How fix error in the WordPress loop?
- what’s the syntax for if the image exists get the image?
- Problem with Displaying Custom Theme Page’s Content
- Efficient way of querying for a “fallback” post?
- PHP: Why does my code work in index.php but not a widget?
- Loop 1 user randomly
- Create a hierarchical loop at predefined markup requirements
- enumerating custom taxonomies?
- How to display thumbnail if post is assigned one otherwise not
- Show results for multiple page-types
- get_template_part() to render single page Theme
- Pagenav Not appearing on custom Template
- Display selected parts from selected pages on the frontpage?
- Remove the_content From Loop
- Adding if statement to content for homepage
- Pagination in category.php not functioning
- How to create a loop that will display one post and stop?