WP_Query
defaults to getting posts, not pages.
From the above reference page:
Display content based on post and page parameters. Remember that default
post_type
is only set to display posts but not pages.
This code:
// WP_Query arguments
$args = array(
'post_parent' => '4117',
'post_type' => 'page',
'posts_per_page' => '1',
'order' => 'DESC',
'orderby' => 'menu_order',
);
// The Query
$query = new WP_Query( $args );
$posts = $query->posts;
foreach ( $posts as $post ) {
echo $post->post_title;
}
…should do what you want.
Related Posts:
- Use REGEXP in WP_Query meta_query key
- Why is the loop not empty on some 404s?
- Multiple custom fields for ‘orderby’ in ‘WP_Query’
- How to order by post_status?
- How to paginate wordpress [gallery] shortcode?
- wp_query->max_num_pages always returns 0 on custom post type
- get_template_part in for loop
- How to display post from current Taxonomy in archive page?
- Getting attachments by meta value
- Display recent posts from the same category as current post in sidebar
- Using is_main_query to select custom post type on certain page
- WP_Query ordered by custom field that is a date string?
- WP_Query with LIKE in meta gives strange query
- WP_Query not working as expected for attachments and custom meta_query
- Group posts by meta_key
- How to Get All Posts but the Private ones?
- How can I hide posts that are over 2 years old
- WordPress custom search form with pre_get_posts not work
- Custom URl parameter
- order by multiple meta keys in pre_get_posts
- Order By Multiple Meta Fields
- WP_Query Performance Issues with meta_query
- WordPress: Keep order of query_posts list of post ID’s using post__in
- Advanced WP Query hogs the SQL server
- How to get user_id from wordpress database inside ajax function?
- How to combine meta_query and post__in in WP_Query
- Is it faster to query records using $wpdb instead of Wp_Query?
- Display posts if specific country
- query user display_name failed in a custom mysql query foreach
- Meta box dropdown of custom posts
- Query with custom taxonomy not working
- Query posts by specific word on title
- Date and Category query with filter
- Get posts for which a custom field is not present, with get_posts
- Output an array of terms for a ‘tax_query’ => array()
- add active class based on permalink and url
- WP_Query with ‘rand’, but equal number of posts from the taxonomy terms given
- querying data via $wpdb and get_row
- Combining categories (Query posts with multiple taxonomy terms)
- Filtering out child category posts from parent category archive not working
- wp_update_post not working
- slow query – Search for Media Gallery
- WordPress has a list of reserved words, can I override them, to use one in a query string?
- WP_Query arguments order
- meta_query: check if number exists
- How to order WP_Query to group results?
- new WP_Query messes up pagination
- Search Page Returns Nothing
- How to create custom query by keyword in post title?
- WP Query causing timeout
- get term id from term name
- Woo Commerce using WP_Query to get products that match price range, with an additional required product attribute
- Retrieve select tag custom values from array and display them in current page with wp_query?
- How to use a dropdown to filter posts by custom field
- Use title of post as argument for query
- How can I comment comma-separated array values?
- Content not displaying on paginated page
- Different Loop for tag pages?
- how to load posts to a custom post template after using template_redirect or template_include
- 2 queries with counters
- Orderby two meta fields not working
- Multiple Query_Posts
- WP_Query: attachment image in “full” size?
- Adding pagination to sub-wp_query within a singular post page
- Page template doesn’t display simple HTML if inserted into other page?
- How can I build a query that returns all attachments of a page and it’s children pages?
- How to add date_query to meta_query array
- Order by the first array within a meta_query
- Multiple nested meta queries
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- get_post_format is not returning standard
- Duplice post with standard WP loop – fixed by using query_posts() instead
- Get categories within specific term
- Custom query for custom post type not getting correct post ID
- How to merge these two post queries?
- Exclude parent categories from recent posts list
- How can I query a radius of coordinates?
- custom excerpt is not being shown
- Filtering WP_Query based on wp_postmeta keys values
- Show posts by category – category ID not working
- WP_Query to Retrieve Posts from WooCommerce Products that are Only in Catalog
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- query_posts based on a meta_key
- wp_get_attachment_image not to get the post_thumbnaill
- Query with two posttypes and two different meta_keys
- Sort by meta key within same day
- Duplicates When using Nested WP_Query
- meta_query not working with the_content()
- WP_Query to show post from a category OR custom field – Not 100% answered
- Show portfolio items in template – how?
- Pagination in custom query in a category page
- WordPress WP_Query Array Custom search via taxonomies
- Problem with WordPress 4.0 and $wp_query
- Add category and user name to recently updated post list
- Pagination in WP query with transient API
- WP Paginate not working properly
- How to get child pages and add unique class only to active page?
- Main loop querying current template’s info only in custom category archive pages, not my posts
- How can I display sticky posts at first in wp_query?