I’m not sure why you are comparing anything when you would normally just query a meta_key
for a certain day, maybe I mis-understood the question.
The structure would be something like:
meta_key => day // or $variable
meta_value => Monday //for example
Then you just query posts for a particular day which has a meta field value that matches.
For example using pre_get_posts
to alter your main query to only get posts where the value is equal to the actual day.
function wpse_78591_date( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$today = date("l");
$query->set('meta_key', 'day');
$query->set('meta_value', $today );
}
}
add_action( 'pre_get_posts', 'wpse_78591_date', 9999 );
or in your example it would be:
$args = array( 'post_type' => 'nightclub' , 'posts_per_page' => 10, 'key' => 'day' , 'value' => $today );
In my example I have hardcoded 'key' => 'day'
but you can use a variable instead.
Related Posts:
- Can’t pick up a field created with Advanced Custom Fields
- Get month and day from a Date Picker custom field
- Search that will look in custom field, post title and post content
- Filtering a WP_Query meta_query by numeric values isn’t working
- Sorting a query by custom field date
- Automatically fill custom field value on post publish/update
- Filter a custom field based on selection of another custom field (ACF) [closed]
- ACF Relationships in Custom Post Type Permalink
- How to sort a table of custom posts by column containing custom field
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- List events by month
- Use Custom Post Type as Custom Field
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- WP insert post PHP function dynamically generated Custom Fields
- Show ACF field from custom taxonomy and display on the single template
- Change message given when deleting post from custom post type
- Display posts if a custom field value is equal to another custom field value
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Get Custom Field Values by Another Custom Field in WordPress
- How to Display ACF Relationship Custom Field as Link to Specific Custom Post?
- Query Custom Post Types by date (custom field) range
- Conditional to modify query results
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- How to get a custom type post data when it has a connection with another custom type post?
- Sort a custom post with ACF: Date Picker & Display Featured!
- List of users that clicked a ‘Join’ button at single post
- How to inherit field value from parent post into in child / sub post
- finding and using post type fields in WordPress
- Custome fields not displayed
- Create short URL with auto 301 redirect
- Get data from PHP to JavaScript to set position of each post on front page
- Query entries from custom post type in an ACF flexible content field
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Sum and count of custom field values
- Group by custom field value (start and end times)
- Custom post types, disable fields
- meta query not retrieving posts
- Incorrect ordering of custom post type based on time
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- How do I show my containing my custom field ONLY if there is a set value on that custom field? [closed]
- CPT Repeatable Fields + Undefined Index
- Let users upload image(s) to the post from front end
- Excerpt length: get first paragraph
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- Create if else for post types in WP_Query ‘post__in’ values
- Alike Shortcode using in Custom Shortcode
- Grouping custom wordpress post types by acf value
- Query custom post type that has a serialized relational advanced custom field value
- Sort custom post column by generated value?
- WordPress – display relationship between blog posts and custom posts
- when looping through custom post data not appearing
- Custom sorting in post columns by ACF Pro Select Field
- Load info from customposttype into template page
- Display Custom Field or Custom Taxonomy in front page /post/product
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- filter using custom fields
- Autofill advanced custom field with user data
- Advanced search form with multiple custom fields
- PHP Notice: Unidentified index
- CPT: execute code after load if parameter is set
- ACF Post Content Not Being Searched
- Display related post content and custom field content
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Fixed custom fields depending on posttype/category
- Automatically convert standard posts with custom fields to custom post types
- WordPress loop add heading before first of type
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- How to make a shortcode for my WP_Query Loop? [duplicate]
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Custom post tag images not displaying with ACF
- Function not pulling image or text from custom post type
- Show Custom Post Type taxonomy term that matches custom field
- using ACF datepicker to filter posts on a page
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Order by custom field attribute
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Custom Post-type not returning the right child_of
- Select Menu for Custom post Type does not save
- How to show animal lineage/pedigree in WordPress?
- How do I filter a custom post type loop by a field?
- ACF – Query relationship without ID
- Get custom post fields and display them
- Getting ACF relationship field information
- Retrieve a post with its ACF repeater fields in wordpress
- How to I add count of custom posts listed in a post as a prefix to its title
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Send email on creation of custom post type and use get_post_meta()
- Display ACF object field data using Elementor Custom Query
- Post object GUID adding http:/
- Custom Sort Order for Custom Post Type Taxonomy
- Meta query with ACF relationship field
- Use Custom Field to Display Post Loop
- How to automatically update ACF field value every year?
- ACF – Updating all posts of CPT when a custom field from options page is updated