I would like to order my Repeater Field “telechargement” from the date ($fichier_date) :
<?php
while( have_rows('telechargement') ): the_row();
$fichier_url = get_sub_field('fichier');
$fichier_titre = get_sub_field('intitule');
$fichier_date = get_sub_field('date');
?>
<div><?php echo $fichier_date ?> - <?php echo $fichier_titre; ?></div>
<?php endwhile; ?>
Have you an idea ?
Thank
Hi @jluc73,
Thanks for the post.
The first step would involve the creation of a custom filter to replace the standard ‘=’ with ‘LIKE’ in the SQL query, this is to allow for a WILDCARD in the meta_key search.
The query will look like so:
// filter
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'dates_%", "meta_key LIKE 'dates_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
You can then order your posts like so:
$args = array(
'numberposts' => -1,
'post_type' => 'post type',
'orderby' => 'meta_value'
'meta_key' => 'telechargement_%_date,
'order' => 'ASC'
);