Support

Account

Home Forums Front-end Issues Arrange custom post type by meta key value

Solved

Arrange custom post type by meta key value

  • My query works fine to pull out all my posts with a value of ‘ALBUM’, but I now need to further sort those posts by a value called ‘RELEASE_YEAR’.

    I am having trouble incorporating that second meta_key query in to my results.

    How would I add to the below to ensure all posts are sorted by ‘RELEASE_YEAR’ field?

    Any help appreciated.

    <?php 
      $posts = get_posts(array(
      'post_type'           => 'discography',
      'posts_per_page'      => -1,
      'meta_key'            => 'release_category',
      'meta_value'          => 'album',
      'orderby'             => 'meta_value',
      'order'               => 'ASC',
      ));            
    if( $posts ): ?>
  • This has not been solved.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.