I’m afraid WP_Query is not able to fetch (Posts with custom field) or (ailec_even). You’ll have to query the firs one, than the second one and merge those arrays. Use WP_Query instead of query_posts.
I’ve just tried it on my local installation and this code called from index.php of twentytwelve works (brings post with title “Hello post” and ai1ec_event with title “Event” – both with custom field “teaser” with value “on”
$events_query = new WP_Query( array('post_type' => array('ai1ec_event', 'post'), 'meta_query' => array( array( 'key' => 'teaser', 'value' => 'on' ) )) );
while ( $events_query->have_posts() ) :
$events_query->the_post();
echo get_the_title() . '<br/>';
endwhile;
Have to say that both (post end event) were created by admin user – I’ve checked the code and there is an extensive part with custom capabilities.
Related Posts:
- Query custom post type by custom field
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- WP insert post PHP function dynamically generated Custom Fields
- Having trouble with custom date field for CPT query (WordPress)
- Sort posts based on multiple custom fields
- Conditional to modify query results
- Querying Two Custom Post Types with OR Not Working
- First custom field value (out of several) displayed twice after query
- How to conditionally add Custom Post Type to Front Page
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- Custom Query: If One Post Object Field Value Is The Same As Another
- Filtering custom posts by custom fields (ACF) [closed]
- updating one custom meta field only
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- WP Query from two Custom Post type fields as statement
- Using OR relation in meta_query to check for a value before sorting by another
- Meta query and compare “!=” not working as expected
- How do I query with multiple custom fields orderby in same column?
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Show first posts with custom field not empty and order all by title
- Filter CPT based on meta box value using Flexible Posts widget?
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Filter Custom post type by another Custom post type
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- Get Posts ordered by a date custom meta field
- Check for custom field value in different post type than current one and do something
- Get the ID of the latest post
- Do_Shortcode not working for Embed
- Sort custom post type list table by display name of a user id stored as post meta value
- Display custom post type and custom fields within a Bootstrap Carousel
- how to filter by last name for custom post
- Search that will look in custom field, post title and post content
- clients list using wordpress
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- add_meta_box: Datepicker like the one for postdate?
- Custom field losing p tags on display
- Using posts and postmeta table to store custom Address Book Plugin data
- Frontend posting – everything saves other than checkboxes?
- Saving repeated option values in a custom query
- Calculating Bayesian average for custom post type
- Query Custom Post Types by date (custom field) range
- handling csv data with a custom post type
- Custom fields in Permalinks?
- How to debug a blank page?
- How to add a Custom Meta Box for more than one Post Type?
- WordPress Orderby Numeric Value Not Working
- WordPress custom loop filter by meta_key and value with serialize data
- Permalink structure by Post Meta value
- Cannot add custom field to “orderby” parameter in Rest API
- Tracking changes in admin-page so user gets warning when leaving the page
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Multiple Frontend Filters Using Advanced Custom Fields
- Number of posts in the archive
- create custom meta box with default value
- Query custom post type based on post id and custom field value
- Add custom attributes to a post
- Custom Taxonomy Search result page
- Get post content from another section in custom single page
- Modify Posts from Custom_Post_Type within the plugin
- How to convert custom fields to content
- Group by custom field value (start and end times)
- Variable Products as custom post types
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Create list from custom field comma separated values
- Get previous and next custom post by custom field
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Create an user checklist system for a course plateform using ACF Pro and ACF Extended
- Query filter by value in meta_value array
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query get always custom post_type for first
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_insert_post deleting previous post custom meta
- Show posts from WP Custom Post Type selected from a field in a metabox
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- Custom Field to post_title
- Automatically convert standard posts with custom fields to custom post types
- Importing URLs of Audio Enclosures
- Retrieving custom post type fields without a post
- Get month and day from a Date Picker custom field
- custom fields not showing before get_header
- pre_get_posts with multiple post types AND a meta_key
- Search form to find custom meta box generated data
- Display Custom Post if custom field is marked
- predefined custom field on registration page
- Show Custom Post Type taxonomy term that matches custom field
- Query child posts on parents single.php?
- WordPress can only query up to 766
- Select Menu for Custom post Type does not save
- Allow authors to create article image
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Allow admin to determine the order of queries?
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Display ACF object field data using Elementor Custom Query
- Sortable admin columns ordering from custom fields isn’t combine com search and Dropdown filter
- How to consume external API from WordPress post editor and display the response data in the custom field?