[resolved] WP_Query - multiple custom post types and sort by custom meta (2 posts)

  1. martin_666
    Posted 2 years ago #

    Hello guys,

    I'd like get results from two custom post types and sort them by custom meta (date of start events).

    This code:

    $warsztaty_q = new WP_Query(array(
    	'post_type' => array('kalendarium', 'warsztaty'),
    	'order_by' => 'meta_value',
    	'meta_key' => 'data_start',
    	'order' => 'ASC'

    Would be ok but first sorted is 'kalendarium' and then 'warsztaty' so in query results first sorted are posts from 'kalendarium' and next from 'warsztaty' not together.

    I found this solution:

    But I can't get custom meta :(

    Anyone can help me? :)

  2. martin_666
    Posted 1 year ago #

    Problem resolved. Should be 'orderby' instead of 'order_by'

Topic Closed

This topic has been closed to new replies.

About this Topic