Support

Account

Home Forums General Issues Order by with a custom field on get_posts not Working

Unread

Order by with a custom field on get_posts not Working

  • sorry for my bad english.

    i got this code:

    $consumibles = get_posts(array(
    							'post_type' => 'consumibles', 
    							'meta_key' => 'orden', 
    							'orderby' => 'meta_value_num',
    						    'order' => 'ASC',
    							
    							'meta_query' => array( 
    							'relation'=>'or',
    								array(
    									'key' => 'marca', // name of custom field
    									'value' => 'evolis', // matches exaclty "123", not just 123. This prevents a match for "1234"
    									'compare' => '=='
    								),
    								array(
    									'key' => 'marca', // name of custom field
    									'value' => 'todos', // matches exaclty "123", not just 123. This prevents a match for "1234"
    									'compare' => '=='
    								)
    							)
    												));

    i am trying to sort by orden a custom field, but only works with out the meta_query part is anyone knows why?

    Thanks in advance

Viewing 1 post (of 1 total)

The topic ‘Order by with a custom field on get_posts not Working’ is closed to new replies.