Support

Account

Home Forums Add-ons Repeater Field Repeater Plugin – Group By Help Reply To: Repeater Plugin – Group By Help

  • So may be this example may help:

    $posts = get_posts(array(
    	'post_type'		=> 'event',
    	'posts_per_page'	=> -1,
    	'meta_query'		=> array(
    		'relation' => 'OR',
    		array(
    			'key' => 'location',
    			'value' => 'melbourne',
    			'compare' => '='
    		),
    		array(
    			'key' => 'location',
    			'value' => 'sydney',
    			'compare' => '='
    		)
    	)
    ));
     
    if($posts)
    {
    	foreach($posts as $post)
    	{
    		// ...
    	}
    }

    Or maybe something like this (untested):

    $rows = $wpdb->get_results($wpdb->prepare( 
    "
    SELECT * 
    FROM wp_postmeta
    WHERE meta_key LIKE %s GROUP BY meta_key ASC",
    'Locations', 			
    ""		
    ));	

    I’d be inclined to look at some examples. Maybe try running the SQL in PHPMyAdmin and then convert that into the code you need.