Support

Account

Home Forums Add-ons Repeater Field Echo Repeater-Field alphabetically query_posts Reply To: Echo Repeater-Field alphabetically query_posts

  • Thank you for your hint. I tried alot but have no clue where it stucks. would be nice if someone can give me another hint.

    My repeater-field is “artists“, in there is a sub-field called “artistname“.

    My goal is a list of artistnames played in the past, sorted alphabetically (if possible without doubles, if an artist player more than once in the club).

    So far it displays all artistnames, but not alphabetically.

    My query so far:

    
    <?php
    // filter
    function my_posts_where( $where ) {
    	$where = str_replace("meta_key = 'artists_%", "meta_key LIKE 'artists_%", $where);
    	return $where;
    }
    
    add_filter('posts_where', 'my_posts_where');
    
    // find todays date
    $today = date('Ymd');
    
    $args = array(
    	'posts_per_page' => '-1',
    	'post_type' => 'veranstaltungen',
    	'orderby' => 'artist_clause',
    	'order'     => 'ASC',
       
    	'meta_query' => array(
    	'relation' => 'AND',
       		
    		'date_clause' => array(
    			'key' => 'datum',
    			'value' => $today,
    			'compare' => '<',
            ),
            'artist_clause' => array(
    			'key' => 'artists_%_artistname',
            )
        )
    );
    
    query_posts( $args );
    ?>
    

    Thank you