This is a code I’m using ina website that I’m creating for a client. Maybe it can point you in the right direction:
$current_date = date('Y-m-d');
$args = array(
'post_type' => 'billboard_evento',
'posts_per_page' => 4,
'meta_key' => 'fecha-inicio', //Declaring wich meta key I want to use
'orderby' => 'fecha-inicio', //Ordering the queried elements by meta value
'order' => 'ASC',
'meta_query' => array( //Querying by meta field
array(
'key' => 'fecha-inicio', //meta field name for an event start date
'value' => $current_date, // Setting the value to current date
'compare' => '>=', // Comparing current date with event start date
'type' => 'DATE', //Type of value
),
)
);
$query_eventos = new WP_query($args);
Related Posts:
- How to enable custom fields for pages (if not a bad practice)?
- Best way to programmatically remove a category/term from a post
- display specific custom fields
- Add new “Insert Into Post” button with another function
- Custom per-page sidebar widgets .. possible?
- Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
- How to add new custom page or post blocks?
- Transients vs CRON +Custom Fields: Caching Data Per Post
- How to update serialized data in the user meta data
- Unable to save datetime custom meta field using update_post_meta() function
- Guest Author – How can I use custom fields to create guest author link?
- Best way to allow manageable social media URLS?
- enabling custom fields in admin?
- Adding a custom field or metabox to the post-thumbnail widget?
- Using WP Query to search by multiple meta fields
- Get aggregate list of all custom fields for entire blog
- Sort by posts that have a featured image?
- WP_Query display next custom post from today’s date
- Can ordering post list by meta_value cause performance issue?
- How to Identify the Source of a Custom Field?
- Title and post URL based on custom fields?
- woocommerce product custom field
- Multiple relationships in a query
- two custom fields question
- How to save multiple options from a dropdown in user profile
- How to display multiple images in custom field
- How to show a gloabl message on a user profile page (in back end)?
- Display the contents of a custom field of a page on their child
- Read / Watch / Listen times – meta
- Login WP – Connect single field to an external api
- adding extra wordpress user info from registration form
- Custom Meta Box (SELECT) Not Saving
- Turn raw url into clickable links
- meta fields for the whole wordpress site
- Advanced Custom Fields functionality without plugin
- Get post ids sorted by meta_key
- Advanced Custom Fields Plugin – Unable to get URL from post_object
- Plot location on Google map using full address specified in custom field
- Display custom field value as a hyperlink
- Unable to get specific value from post meta
- pre_get_posts : only get posts by wp_usermeta value
- 3.8 Media Upload and Custom Meta Box
- Displaying Custom Field Array
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- IF Custom field value equals ZERO
- Let’s Create Custom Field Template Documentation
- WordPress Settings API Repeatable fields
- Custom Field Repeating When Using foreach
- WordPress creates new lines in postmeta table on post update
- How to add custom filed value after in wp post title
- Accessing Custom Fields on Pages
- How to add a css class to custom field value?
- Display a different image for each page with editor
- Help setting up a sql query
- Advanced Custom fields not available yet during publish_page action
- Meta box values are displayed on Custom Fields list. Is it possible to hide them?
- Sort posts by custom field value
- WP_query multiple custom fields not working
- Help with this custom field conditional if no field is set display nothing
- if statement display content even though no data
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Get custom post fields from multiple metaboxes
- Get author total post votes from post meta
- Only admin should be able to add a particular custom field
- How to display custom fields in hestia theme
- How to update only certain custom fields in a the cache of a page?
- Custom date column in user table not sorting correcting
- pass custom value from single.php to another file via get
- Custom Fields displaying in single line
- variable not passed correctly to database using custom field
- WordPress Blocks, setAttributes not saving
- non-unique #_ajax_nonce id in browser console
- How do i call up default post title in custom posts
- How to save multiple custom user profile fields using repeater JQuery
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Why does this javascript search function in the WordPress Admin not work?
- 4 Unique Random Posts based on Custom Field Values
- Page template is missing fields or is invalid when I updating the template
- create a custom field that let me include other posts
- Check if value exists before saving
- Get meta value when the page is a blog archive
- Add Image With Changeable Link in Custom Field [closed]
- Term specific featured post on taxonomy archive pages
- Thirtieth century date for a post
- Saving metadata of related post on save_post
- Custom field in external Javascript
- Custom field value link title
- How to Order Posts by Custom Fields?
- Analyze uploaded images to get colour values
- Turn Current Date in Custom Field Ouput Green or Red
- added a meta box to post however when saving menu while debug on throws a warning
- How can i get the actor birthday by date?
- Post rating using Custom Field
- Inserting custom fields into new-post.php without using the Custom Fields Template plugin?
- Make Custom Fields Public in JSON – API
- Advanced Custom Fields for Header that are Editable from a Page [closed]
- Shortcode not picking up custom field
- Order by a meta field in query loop
- Multiple permalinks for a single post from custom field
- Search for meta_query does not return any result if combined with title