$the_query = new WP_Query( array( 'post_type' => 'page', 'parent' => 42, 'child_of' => 0,) );
You should edit this line like following:
$the_query = new WP_Query( array( 'post_type' => 'page', 'post_parent' => 42) );
Related Posts:
- A check for if is parent page, if has children, if has grandchildren
- Can I display submenus in groups, using wp_list_pages?
- Only allow new subpages to be created
- Create subpage – filter parent pages list
- How can I automatically add child pages to pages in a WP menu?
- Keep page hierarchy in wp_list_pages, even if on a child or grandchild
- Get all children titles of a page as a link to them
- Multiple Loops That Pull Pages (Child/Grandchild) While Styling the First Entry
- Search anything from a Child and Sub-Pages of their Parent page
- Show children connected to parent pages
- 1st Level Page with No Children
- how to list subpages in sidebar without widget
- How to get current page ID outside the loop?
- Get the content of a specific page (by ID)
- featured image as background image on pages
- Show Default Editor on Blog Page ( Administration Panel )
- Order by menu_order and title?
- WP Page and Subdirectory with same name
- How to redirect on particular page in wordpress? [closed]
- How to inject custom url path for page ?
- How to display page title+link of page created by user
- get_page_by_title not working when used with a variable
- WordPress twenty eleven sidebar on Pages
- Debugging shortcode problems
- How to disable Page Attributes dropdown in wp-admin
- How to show updated edit on preview URL without clicking preview button
- Editing Pages that Have Already Been Published
- How to redirect a page to subdomain?
- Getting child content
- Clean URL link for page without number
- How can I have two content titles?
- Get the Page Content,without generating HTML
- How can I split long posts into pages?
- Slug is redirecting to 404
- Include content from one page to another
- Adminbar Missing “Edit Page”
- conditional tags- how to use with shortcodes
- List all private pages user has access rights to read
- “next page” of parent in infinite loop
- Access the same page from multiple urls (wildcard)
- How to update the counter of private pages in the dashboard?
- Layout Builder.
- Edit custom HTML page from WP admin dashboard
- Pass data from one page to anothe file/page in wordpress
- Get the Current Page Slug-Name
- Display child pages in a parent page? [closed]
- How to use is_admin in page content?
- Why isn’t WordPress respecting my HTML?
- From a developer’s point of view what are the differences between pages and posts? [closed]
- block a page from logged out users and redirect to homepage
- Edit page shown after login in WordPress?
- Disable ADD PDF media button on rich text editor
- invalid argument in foreach when trying to list custom post types in archive.php
- WordPress page not taking precedence over server directory
- How to properly enable comments form in page template
- on page creation few inline style properties gets removed
- Custom folder for wordpress page templates
- way to make all pages with certain tags public?
- Page not appearing under its Parent
- Separate URL for a specific page
- Pages that don’t look like blog posts?
- Can I use Pages like a Wiki
- list child-pages as normal pages?
- return page name in url
- Next and Previous Page links based on ‘Order’ attribute
- Create multiple pages with tables from json file
- Can i use 2 page content-forum & content-forum-slug on bbpress?
- Attaching a file to a page without adding to media library?
- Change page width in refined magazine/mag and news theme
- Every change made by “Author” role is going to “pending review”
- Groping Pages Per Department Option
- Requiring a Visitor to Enter a Password Each Time They visit a Page
- Display meta data attribute in user profile
- WordPress default theme cannot get full page on entry content div
- WordPress displays widgets out of whack
- How to remove the duplicate title tags and duplicate meta descriptions?
- WordPress form submit to custom page template does not work
- Two different layouts for the same post
- My page title turns into a h2 tag – What to do?
- How do I locate a third party page represented as a slug in my WordPress website?
- Customise the_title in admin area
- problem with loading pages
- How to turn post into pages and via versa?
- Content not displaying on page
- Blank white space where header was [closed]
- Featured Image not displaying in a page
- Display child pages on homepage template
- Set order acs and no paging for archive page
- Pageview all of sudden not working
- Childpage title + content on Parent Page
- Filter posts by author selected in page
- search page different results
- List Parent page with sub pages
- simple category search form returns full text – but I need excerpts
- Naming custom page templates
- How can I use Page editor for two separate templates?
- Sort the data in WordPress using get-page-by-title
- Adding a filter to wp_edit_posts_query() to prevent hierarchical display of pages
- In WP, Google map error initMap is not a function [closed]
- WordPress is picking up links that don’t exist