You need to add a meta query, which will specifically select those posts that have both the meta key you want, and the desired value.
$args = array(
'post_type' => 'pages',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'use-this-page-as-a-section', // or whatever the key is
'value' => 'yes'
)
);
Related Posts:
- Multiple orderby values in WP_Query
- Enable sticky posts to custom post_type
- Search multiple custom fields by using meta_query
- WP_Query orderby custom field then post_date in one query
- how to filter by last name for custom post
- How can I add a column/s to wp_posts table?
- Filtering a WP_Query meta_query by numeric values isn’t working
- Sorting a query by custom field date
- How can I generate a RSS feed based on a custom WP_Query?
- Filtering a WP Query result
- Display Custom Post Type Fields
- How to hook get_terms() to only show count of posts that have custom meta
- Search Custom Post Type with all meta attached?
- How to sort CPT by custom meta value (date), and return posts month by month
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- Wp-query causing problems with the_content();
- How to create posts (not post template) to be displayed on projects page?
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Get post info inside modal window?
- add_meta_box: Datepicker like the one for postdate?
- WP Query group/order by category name
- Multiple information using custom post type
- Having trouble with custom date field for CPT query (WordPress)
- Quickest way to get last or oldest post date – WP Query
- Display posts if a custom field value is equal to another custom field value
- Sort by two dates. Default entry date and custom field if present
- Before Delete Post
- How do I create an archive page for standard posts?
- How to use custom fields to enable sticky posts on custom post types?
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Conditional to modify query results
- Loop on front-page.php
- Filtering by Post Meta Custom Fields – Performance
- wp_query to find posts by year and month
- WP_Query is printing out only one post when posts_per_page is set to multiple
- SEARCH QUERIES – REVERSE OUTPUT
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- Query custom post type and custom field by URL parameters
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- Post Filtered by Custom Field Value
- minimize wp_query call to database
- subtracting the current post form then whole loop, which is generating all CPT titles
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- post type => ‘any’ not applied my custom queries
- Custom Post By Category
- sorting in wp query based on custom field value
- Custom post Query and WordPress Post Query Clash
- How to get the posts that my following users are liked?
- Meta_Query refuses to return results
- WP_posts (Not meta) extra custom field column show and change it in a custom post type
- Get post from Category by Priority
- Most efficient way of showing children posts?
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- Only show current category post
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- Query events post type after current date and timezone
- How To Loop Through list with Custom Post Types
- How to stop wp_query searching pages as well as the specified CPT
- Selecting posts older than the current Unix epoch timestamp
- WP_Query and two custom fields returns no posts
- WP_Query get posts where post_name is empty
- Storing/querying custom date data
- Retrieving IDs of child pages which are in a different post type
- Query Posts From Multiple Post Types
- custom field suit new post with in custom fields
- Change display wp post type to wp custom post type
- Query recent posts by author
- 404 on Pages for Custom Post Type & Query_Posts
- Dynamically change post_parent in every page load?
- Querying meta values within an array
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Filter Custom post type by another Custom post type
- Cannot exclude particular post from loop of custom post type
- Show Posts in Vertical Tabs with Scrollbar
- How do I hide single category post on my post page
- How to show all posts of specific custom post type with their custom fields values?
- Wp-theme Development
- show the most recent date of all posts to display on front end
- querying to custom field over ACF REST API
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Display code if title of the custom post matches title of other post
- Sort CPT by taxonomy AND THEN by custom field
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- Sort ACF by custom taxonomy
- Query order by a numeric ACF field
- WP_Query not using relation key as expected and not producing any results
- Use Custom Field to Display Post Loop
- How to automatically update ACF field value every year?
- WP_Query for multiple post types just shows one