• Hello. I have a query:

    $args = array( 'cache_results' => false,
    
    'update_post_meta_cache' => false,
    
    'update_post_term_cache' => false,
    
    'post_type' => 'estate_property',
    
    'post_status' => 'publish',
    
    'paged' => $paged, //1
    
    'posts_per_page' => $prop_no, // 10
    
    'meta_key' => $meta_order, // 'empty'
    
    'tax_query' => $tax_array, array[filled array]
    
    'meta_query' => $meta_array, );

    how can i sort by post_title ? Or by creation date? or by price? (meta property_price)

    when added to array ('meta_key' => $meta_order, // 'prop_featured' [orderby] => meta_value_num [order] => DESC or ASC) nothing changes. what to do?

    • This topic was modified 1 year, 4 months ago by bcworkz. Reason: code format fixed

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    “orderby” belongs as a key in the main $args array. Do not nest it into any sub-array.
    'orderby'=> 'title',
    or
    'orderby'=> 'date',
    or

    'meta_key' => 'property_price',
    // Do not include a 'meta_value_num' arg key/value pair.
    'orderby'=> 'meta_value_num',
Viewing 1 replies (of 1 total)
  • The topic ‘Sorting records’ is closed to new replies.