Support

Account

Home Forums Front-end Issues custom query with order by number (range)

Helping

custom query with order by number (range)

  • hello, your plugin is very perfect. I use it in my site ( pixeltv.it ), I use in review, for all specific, for valutation, and for google structured data. Its all perfect.

    Now I would like to create a dynamic ranking query, this code in your site is god for select different field:

    
    $posts = get_posts(array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'post',
    	'meta_query'	=> array(
    		'relation'		=> 'AND',
    		array(
    			'key'	 	=> 'color',
    			'value'	  	=> array('red', 'orange'),
    			'compare' 	=> 'IN',
    		),
    	),
    ));
    

    but I would like this code to list the results in order of the custom field “range” with numbering from 0 to 100 (descending order)

    for the numbering I used the custom field “range” with the name “total_review”. it’s possible ?

    thanks for support

  • 
    $posts = get_posts(array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'post',
    	'meta_query'	=> array(
    		'relation'		=> 'AND',
    		'range_clause' => array(
    			'key'	 	=> 'range field name',
    			'compare' 	=> 'EXISTS',
    		),
    	),
    	'orderby' => array('range_clause' => 'DESC')
    ));
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.