The answer by felipelavinz assumes that there is an array of dates stored in the post_meta of each post, but the way I read your question and sample code it seemed as though you have one date specified per post? If this is true (one date per post)
then the following would suit you better
<?php
// this is the correct equivalent to the get_posts call
// Don't use get_posts.
// you should also specify some "orderby" parameter
$entries = new WP_Query(array(
'post_type' => 'cw_events',
'posts_per_page' => -1,
'order' => 'ASC'
));
dates = array(); //we will fill this up with dates in the loop
if ( $entries->have_posts() ) : while ( $entries->have_posts() ) : $entries->the_post();
//WP_Post magic methods allow us to access meta values like so
$dates[] = $post->event_date;
endwhile; endif;
$dates = array_unique( $dates );
// always user wp_reset_postdata() UNLESS interacting with the main query
wp_reset_postdata();
Related Posts:
- How to update single value in multi dimensional Post Meta?
- Modern Tribe Calendar wp-query with meta query not working at all
- Sortable admin column for one meta key with three possible meta values
- Can an array be used as a meta_query value?
- List of posts by day of the week
- How to convert objects into arrays
- How to use array in function to get only value I want
- MySQL Query Returns Array () In Shortcode
- Convert a column of a table containing an Array as response in HTML
- Usermeta data unserialize, extract and display in table in WordPress
- How to insert multiple rows and columns in database using array
- How to display MySQL table data which is stored as an array?
- How can get all users by current user meta (array)?
- Transaction when using WP functions rather than vanilla SQL?
- Can i use php sql functions instead of $wpdb?
- Sorting list of sites from multisite network using wp_get_sites
- How to validate WordPress generated password in DB using PHP?
- Custom query to get post names beginning with a digit
- How To Make Connection To WordPress Data Base In A Plugin?
- How to merge local and live databases?
- How to track a users progress through pages by inserting data into WordPress Database?
- the_author_meta not working
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- mysqli_real_connect() – authentication method unknown to the client Warnings
- Do I need to prepare query before get_results(), get_row() and get_var()?
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- How to select WooCommerce products by post_meta and order them
- Parsing php string in jquery [closed]
- Working with query_posts ( arrays and query strings)
- Remove one value in dismissed_wp_pointers?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- Call global variable array() in woocommerce child/template
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- I want to select the from values from database in WordPress? [closed]
- User management system similar to wordpress one?
- Populate dropdown with Child Pages based on Parent Page chosen
- SQL Injection blocked by firewall
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- How can I save unique user data on my site? [closed]
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- Long running queries
- Using custom tables for old posts
- Alter required message using comment form api
- get_users meta_query: REGEXP not working for matching new lines
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Multiple meta_key in one global $wpdb;
- WordPress member notification
- Moving wordpress site from localhost to live server using GoDaddy cPanel
- How does WP work in conjunction with a web server?
- How to array only one key from another array
- Filtering a function’ output for a new continued function
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Location of core code for database connection and get_header
- Creating Database Table vs. Adding MetaData to Post & User
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- How to update and save user metadata on page visits?
- Most commented posts by time period (last 12h, last 24h and etc)
- How to get specific attribute from DB
- If Array Values Match Another Array’s Values, Then
- Hide posts if user is added to it WP_query
- WordPress loop by meta key that is an array? and how loop multiple arrays
- How to unserialize data from MySQL
- I’m unable to call img path using single quotes in an array?
- Known Issues in WordPress When Upgrading PHP to ver 7
- Comapare get_user_meta value
- How can get all users by current user meta?
- Get the id of the row from database on click of a button [closed]
- SQL error with custom query
- Modify WooCommerce used to get all orders in dashboard
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- Sending simple variable on single page to WP JSON
- Display Results of SQL Query on WP site
- in_array not working on dev server but works on localhost
- meta_query search names when they have middle initials
- Weird fonts showing which are coming from database
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- WordPress Bad Request Error 400
- I am facing this error Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- What is the correct way to search 3 custom fields only in WordPress?
- cant insert data in a custom table in phpmyadmin
- autocomplete in wordpress using ajax with json-data
- How to filter specific element of an array in wordpress/php?
- Remove item from post_meta array via AJAX
- New database entry to trigger runing PHP/SQL query through link with token, without logging into the website
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Query doesn’t display text data with apostrophes
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- I want show only data for today
- SQL Query Search page
- Display Content Based on Custom Field Value
- Reformat data within a nested array
- How to find the function which is outputting Array
- How to set if meta_value is lower < than other meta_value in a get_posts array?
- How to pass username into form that sends data to database
- PHP Use Declared array Variable inside already Declared Array
- Your PHP installation appears to be missing the MySQL … After deleting and restarting from cpanel
- Adding date and time to the same request
- Search custom post type posts only by meta fields?
- running an existing WordPress site from Visual Studio Code?