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
- Filtering a WP Query result
- Display Custom Post Type Fields
- 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
- 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
- Before Delete Post
- 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?
- Filtering by Post Meta Custom Fields – Performance
- WP Query—Relationship between two custom post types and their fields
- How to dynamically attach pictures to a carousel
- WordPress Orderby Numeric Value Not Working
- is there a way to retrieve posts that do not have a featured image assigned?
- Custom Post type and Custom Field WP_Query
- WP_Query: include custom post type only with specific meta value
- WP_Query orderby modified to include custom meta changes
- WordPress custom loop filter by meta_key and value with serialize data
- Returning a list of custom post types excluding those without a specific meta_value
- Storing posts from query and accessing later via AJAX call
- Update Post Meta for a logged in user
- Problem querying Custom post type by custom fields
- WP_Query order by custom field, then randomly order some of results
- Query Multiple Custom Posts by Custom Fields
- Get Posts by multiple custom fields is not working
- Several post types on WP Query by tag and taxonomy
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- First custom field value (out of several) displayed twice after query
- How to get all tags of a custom post type by id
- Query based on custom fields start and end date
- Redirect to another page using contact form 7? [closed]
- WP the_posts() on single-cars.php get category link
- Different Limit number of post on different archive page
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- Display post from a date range from custom field
- Custom post types and ‘new WP_Query’
- post_per_page ignored in WP_Query
- Variable not working in WP_Query
- Getting a custom post’s custom field based on another custom post’s custom field select
- WP_Query orderby not work with meta_key
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Query within a foreach within a query (queryception)
- Display custom post type for specific user
- Custom Post type loop with ACF not displaying properly
- How to query Posts from a custom post type which contains a custom taxonomy?
- Display post from custom post type
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Checking for custom field in admin pages
- A sports wordpress website
- WP query_posts group by meta field related
- Display custom post front end filter by ACF equals current user
- Custom Form / Search with Custom Post Type Data
- Create if else for post types in WP_Query ‘post__in’ values
- WP Query from two Custom Post type fields as statement
- Display Parent-Child Posts in specific order by comparing IDs in array
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query get always custom post_type for first
- How to display custom field in product description?
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- wp_post_delete is deleting all offices
- 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
- 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
- subtracting the current post form then whole loop, which is generating all CPT titles
- post type => ‘any’ not applied my custom queries
- Custom Post By Category
- How to get the posts that my following users are liked?
- 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?
- How To Loop Through list with Custom Post Types
- Selecting posts older than the current Unix epoch timestamp
- WP_Query get posts where post_name is empty
- custom field suit new post with in custom fields
- Change display wp post type to wp custom post type
- Query recent posts by author
- 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
- Wp-theme Development
- show the most recent date of all posts to display on front end
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- How to automatically update ACF field value every year?