I think you can do a left join :
left join
$wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and
my_field_meta.meta_key = 'subscribe')
Where “subscribe” it’s the name of your custom field. So your code could be:
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(p.post_date)
FROM $wpdb->posts as p
LEFT JOIN
$wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and
my_field_meta.meta_key = 'subscribe')
WHERE MONTH(p.post_date) = '$thismonth'
AND YEAR(p.post_date) = '$thisyear'
AND p.post_type="post" AND p.post_status="publish"
AND p.post_date < '" . current_time('mysql') . '\'', ARRAY_N);
Related Posts:
- what is the correct way to compare dates in a WP query_posts meta_query
- Order by meta value or date?
- Filtering posts by post meta data
- Custom query with query_posts doesn’t show post without certain meta_key
- How to sort by meta value?
- get_post_meta causes database queries
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- Querying posts with meta value that begins with a certain pattern
- using multiple meta_key and meta_value in query_posts
- How can I sort homepage by a meta value?
- IF.. post meta show… Conditional Tag Help…?
- order posts by meta value on posts page
- Query_post($args)
- query_posts() on key’s value, or key’s existence
- meta_compare seems to be treating values as strings instead of integers as expected
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to retrieve an array of post IDs by a particular value stored in a custom meta’s array
- Query posts by meta_key whose value is an array
- Unable to get specific value from post meta
- Exclude posts by post meta value
- Frontend form with multiple posts
- query_posts orderby postmeta [closed]
- Get author total post votes from post meta
- How do i create a custom post query when the meta value is an array?
- Ordering Posts By Meta Data
- Limiting the amount of posts this displays
- How to Get All Posts with any post status?
- posts_per_page no limit
- Custom query with orderby meta_value of custom field
- Can I exclude a post by meta key using pre_get_posts function?
- Advanced search form with filters for custom taxonomies and custom fields
- How to update custom fields using the wp_insert_post() function?
- Can wp_query return posts meta in a single request?
- How can i get count from query post
- query_post by title?
- Why query_posts() isn’t marked as deprecated?
- Alternative to query_posts for main loop? [duplicate]
- how to query posts by category and tag?
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Difference between meta keys with _ and without _ [duplicate]
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- Orderby meta_value only returns posts that have existing meta_key
- What is the index [0] for on post meta fields?
- Using meta_query, how can i filter by a custom field and order by another one?
- How do I query by post format in WordPress 3.1
- What is “meta_input” parameter in wp_insert_post() used for?
- Display posts of the last 7 days
- Query Posts or Get Posts by custom fields, possible?
- Is there a way to exclude the content from the post variable to save on RAM usage?
- How to enable revisions for post meta data?
- Return all custom meta data for one custom post type
- The “_encloseme” Meta-Key Conundrum
- Best way to programmatically remove a category/term from a post
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- Query posts by custom taxonomy ID
- Display/query post formats
- Using get_post_meta with new_to_publish
- How to filter custom posts by tags and custom fields?
- Custom field values deleted when trashing custom post type
- How to get all custom fields of any post type
- How to query post by user role?
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- How to return results of a get_posts() in explicitly defined order
- Custom field metabox not showing in back-end
- How do I Paginate Search Results for Custom Post Types?
- Help to condense/optimize some working code
- So much data in postmeta
- Can I count the number of users matching a value in a multiple value key?
- How to set posts per page using WP_Query()
- query_posts exclude a meta key
- How do I create a random post that will last for a day
- Ensuring sticky posts are retrieved first (without using two queries)?
- Getting attachments by meta value
- When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
- Determine if more posts are available than was asked for in `query_posts()`?
- How to hide meta box values from custom fields list?
- Auto sort the wp-admin post list by a meta key
- Modify main WordPress loop with a parse_query filter
- query_posts() in function makes global $wp_query out of sync?
- get_post_meta() unserialize issue – returns boolean(false)
- What is the advantage of the wp_options design pattern?
- Limiting query_posts to 1, regardless of sticky post?
- How to make “sticky” pages (and query by them)
- meta_query where value is equal to given value
- Storing meta fields multiple times OR once with multi dimensional array?
- Query posts: how to exclude results if post is in multiple categories
- Update all posts automatically when using post_meta
- Allow user to create instances of custom field
- Query Custom Meta Value with Increment
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- Problem with ‘post__not_in’
- query_posts and only show results if a custom field is not empty
- How to order posts by descending comment count on taxonomy page?
- Display Custom Post Type Fields
- display specific custom fields
- Filter archive.php by custom meta
- Save metabox with multiple checkbox array