If I understand you, you want to filter out faculty members who do not have any awards at the query stage.
Replace your code:
<?php query_posts( 'post_type=mtt_page'); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
with this (untested):
<?php
$args = array(
'post_type' => 'mtt_page',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'awards',
'compare' => 'EXISTS'
)
)
);
$members = new WP_Query( $args );
?>
<?php if ( $members->have_posts() ) while ( $members->have_posts() ) : $members->the_post(); ?>
Note that I believe the EXISTS meta_query comparison only works in WP 3.5 onwards.
As a few people have pointed out – query_posts is best avoided.
Related Posts:
- what is the correct way to compare dates in a WP query_posts meta_query
- Using meta_query, how can i filter by a custom field and order by another one?
- Return all custom meta data for one custom post type
- How to filter custom posts by tags and custom fields?
- Display Custom Post Type Fields
- How to hook get_terms() to only show count of posts that have custom meta
- order by meta_value serialized array
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- Display custom post types with custom date field value (before today) & order by custom date field
- How to insert content from another Custom Post type into Post?
- Custom post type content using custom fields without template
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Adding Page Templates to post but it ignored it
- How to get_term_meta on single custom post?
- Best way to create a search for custom post type by custom field values
- Incorrect ordering of custom post type based on time
- WP query_posts group by meta field related
- Add custom template ‘sub-page’ to Custom Post type?
- Custom taxonomy template for custom fields loop [closed]
- Query Distinct Taxonomies of Custom Post Type
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Display ACF object field data using Elementor Custom Query
- Filter custom posts using auto populated dropdown selectors
- Show a Category X’s custom post type on Category X archive page?
- How do I associate a custom post type with another through a taxonomy or storing an ID in a custom field?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- Cannot add custom field to “orderby” parameter in Rest API
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- retrieve Meta field value from CPT and set those values as Image Meta Field “Title”
- Having unique constraints for custom fields in a custom post type
- 2 Templates 1 custom post type according url
- Querying Two Custom Post Types with OR Not Working
- How can I get the number of custom post type posts that have a specific attachment image set?
- Trash / Draft a WordPress custom post after custom date field expires
- Set a maxlength for the title input in a custom post type
- Posting to a Custom Post Type from front end – user generated content
- Display custom fields from custom posts in RSS feed
- Bulk Update Custom Fields for Custom Post Types
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Visual editor issue by having multiple tiny mce editors in a CPT
- WordPress Custom Fields Won’t Save
- Update Post Meta for a logged in user
- Problem querying Custom post type by custom fields
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Add custom field to Posts and sort by it
- Orderby CPT custom fields not working
- WP_Query order by custom field, then randomly order some of results
- A better way to add a meta box to custom post types
- Rows with custom columns not well formatted after Quick Edit save
- Plugin – Combine Meta Box Input Fields into single saveble record
- Two Custom Post Types Many to Many Relationship
- Show custom post type relationships by taxonomy
- get_post_meta not working on publishing
- Custom taxonomy and custom post type – wrong permalinks and template
- Query custom post type with ACF Date
- Custom setting to show or hide field
- Custom Meta Field – Remove comma from string with str_replace
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Can I override a CPT template on a per post basis with Gutenberg block editor?
- Using custom field content as expression in IF statement [closed]
- Meta Query Not Returning Output Despite Having Matching Values
- How to create a custom post type with additional fields?
- Callback to custom field is not working in WordPress REST API
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Including metaboxes from custom post types in global search — continued
- ACF From & To Date Validations
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Query Multiple Custom Posts by Custom Fields
- Show image gallery from a custom field
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Dynamic dropdown select values depending on other custom field value
- How to render a custom post type template with custom fields using shortcode
- Disable saving posts as draft (make all posts mandatory regardless of the post status)
- Grouping metadatas into one
- Tracking changes in admin-page so user gets warning when leaving the page
- filter custom post in rest api with custom function
- Get Posts by multiple custom fields is not working
- Woocommerce custom field search in custom post type [closed]
- Content vs Template on custom post
- Polylang non-default language ignores tags in WP_Query
- Add custom field in comments form
- Custom Fields for Custom Post [closed]
- Order Custom Post Type by Custom Field Value
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Filter custom post types by a field value
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- How to use custom template files in deeper directory?
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- WordPress Doesn’t Generate Taxonomy Archive
- Custom REST endpoints for a custom post type with custom fields
- A case for Hierarchical Custom Posts
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Hierarchy and access control for Custom Post Types (CPT)
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Custom taxonomy returns 404
- First custom field value (out of several) displayed twice after query
- Meta Query posts not showing on ending date of custom field