Wordpress - Acf - Get Post Multiple Times With Repeater Date Field
I have a custom post type koncerty with custom date field datum, and I'm currently retrieving the posts with this query (which works well): $date = date('Ymd'); $sql = <<<
Solution 1:
I seem to got it working, here's the query:
SELECT p.ID, p.post_content, p.post_title, datum.meta_value as datum, datum.meta_key , featured.meta_value as featured
FROM wp_posts p
LEFT JOIN wp_postmeta featured
ON featured.post_id = p.ID
AND featured.meta_key = 'featured'
LEFT JOIN wp_postmeta datum
ON datum.post_id = p.ID
AND datum.meta_key LIKE'datum2_%_datum_koncertu'WHERE
p.post_type = 'koncert' AND p.post_status = 'publish'AND datum.meta_value >= '$date'ORDERBY featured DESC, datum ASC, RAND()
LIMIT 3I use 'datum2_%_datum_koncertu', because the naming convention ACF uses to save data to database is $ParentName_$RowNumber_$ChildName (see here http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/).
This way the query returns each post multiple times, and to display the date, I just use <?php date("d.m.", strtotime($post->datum))?>
Not sure, if this is possible with wp_query at all.
Post a Comment for "Wordpress - Acf - Get Post Multiple Times With Repeater Date Field"