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
- Can wp_query return posts meta in a single request?
- query_post by title?
- Auto sort the wp-admin post list by a meta key
- Modify main WordPress loop with a parse_query filter
- Update all posts automatically when using post_meta
- Problem with ‘post__not_in’
- Get updated meta data after save_post hook
- pagination in author.php template returns 404 error
- How to break meta values into different items and avoid duplicates?
- ajax delete value from custom field array
- How can update custom meta for all posts
- query recent posts from several categories
- How to get custom field image url of specific size
- Example Query Posts Showing the Latest Post with the Featured Image
- How to order results by date and meta key?
- Order by value in serialized custom field
- Query post with meta_query where date is not in future
- How to display Meta Field Value?
- Show individual author rank from query of cumulative post view count for all authors
- Make the checkbox meta field checked by default
- Custom posts per page does not work with pagination
- how to interconnect custom post types?
- posts_per_page override by default settings
- Group WP_Query by meta_key date
- Order query by meta_value with multiple custom fields
- How to filter query to display posts from parent category only?
- Display random post on a page with post permalink in URL
- Two Custom Post Types Many to Many Relationship
- How to display certain category in the loop from WordPress default post type?
- What WordPress function to use to get meta value by using meta keys?
- How to create a shortcode to print specific values stored in a post meta array?
- Button inside Custom Meta Box triggering the Update Button
- How to load an assets based on custom field value?
- Custom WP_Query for WordPress Search Results with meta_query
- Change order of posts
- Check if post with same meta value exists
- Prevent custom field from being updated after first publish
- wordpress custom loop ascending descending posts by custom field
- WordPress wp_get_attachment_thumb_url full
- Hide custom fields when empty
- How to change default post type / post to media or attachments
- if in category but only with post meta
- How add multiple wp_editor_box to new post
- copy images from custom field to another custom field
- Cannot obtain custom meta information
- Related query shows same image in loop
- query_posts orderby multiple ways
- Can’t Output get_post_meta?
- Can I use WP_Query one time and then filter the results multiple times
- Pagination linking to first page
- Empty meta-box returns publishdate if no value is set?
- show all in query_posts on category.php?
- Problem with writting correctly a query posts args in WordPress
- get_post_custom_values problem, please help
- Custom query looking at multiple custom fields and properly sorting
- post var problem with shortcode loop
- Pre-existing arguments when using queries
- Get posts for each user
- Use WP_query to match post types based on custom field values
- Displaying data from custom fields on a specific category page
- Creating a “Related Meta” type field?
- Query Posts based on custom field value
- update_post_meta not working in function
- If custom field doesn’t exist, or exists and it’s true show title?
- Return only custom post types for the page, not all
- get_next_posts_link() stops displaying at page 4
- Transfer taxonomy to custom field
- Multiple post queries -category,posts per page,orderby
- How do i output images from URL’s added to the same custom field key
- prevent display duplicate titles on main page
- Filter Query Post by Custom Fields(by date)
- add multiple values (array) to post meta_input