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
- 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
- Specific query for custom post type
- 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]
- Add custom field in comments form
- Custom Fields for Custom Post [closed]
- Order Custom Post Type by Custom Field Value
- Filter custom post types by a field value
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Custom REST endpoints for a custom post type with custom fields
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Display post content with respect to its title?
- Hierarchy and access control for Custom Post Types (CPT)
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Prioritize posts in query by meta keys?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Meta Query posts not showing on ending date of custom field
- Cannot save CPT meta box
- Cross reference custom post types
- Adding Page Templates to post but it ignored it
- What’s the equivalent of Hide From Menus on MODX on WordPress?
- Include related custom fields from one post type in another post type’s JSON feed
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- frontend image post uploader
- WP_Query orderby and tax_query
- Is there any way to add a “custom field” to the CPT archive page?
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Displaying Posts from Custom Post Types
- Different Ways to Query Custom Post Types?
- How to Output which matched meta_keys were found from custom_type_posts?
- Multiple Frontend Filters Using Advanced Custom Fields
- Custom Post Fields at the beginning of a Custom Permalink
- Integrate Custom Post Type Events into Calendar
- Possible to filter custom post type with multiple meta data?
- Hierarchical custom fields
- How to get a custom field value of a custom post?
- Fields for different parts of a page
- Is it possible to activate customfield ‘text description’ upon activating the customfield ‘checkbox’?
- Facebook social publisher and custom post type fields [closed]
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- Displaying and searching Custom Posts
- Importing Data from a Non-WordPress database, into WP
- custom comments form for custom post type
- Searching Custom Fields
- How to organise this data within WordPress
- Show fields based on taxonomy selection in editor
- filter search custom field query
- Permalinks: custom structure for taxonomy – tags?
- How to let users choose where to search for posts?
- don’t publish custom post type post if a meta data field isn’t valid
- WebP Fallback for Inline Background Image in Style Attribute
- Query based on custom fields start and end date
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom post type posts don’t show in archive widget
- Custom fields for custom post type
- How can meta boxes be added to “unknown” custom posts?
- Custom “radio button meta box” not saving correctly