Support

Account

Home Forums Add-ons Repeater Field Orderby meta_key only working on first row in repeater

Unread

Orderby meta_key only working on first row in repeater

  • I’m trying to order my posts by repeater fields but it only orders by the first repeater row not all repeater rows on each post.

    Each post has a repeater line_on_form within this is a field called “line_number”. Posts can have more than one line_on_form row. But I want it to sort by both the first row first and the second row second.

    My query args:

    $sub_args = array(
      'numberposts' => -1,
      'post_type' => 'change_item',
      'meta_key' => 'lines_on_form_$_line_number',
      'orderby' => 'meta_value_num',
      'order' => 'ASC'
    );

    Current output:

    <Example post title>
    line on form -> line number 40
    line on form -> line number 44

    <Example post title>
    line on form -> line number 40
    line on form -> line number 13

    <Example post title>
    line on form -> line number 40
    line on form -> line number 23

    Desired output (notice the second line number in each is ordered ASC):

    <Example post title>
    line on form -> line number 40
    line on form -> line number 13

    <Example post title>
    line on form -> line number 40
    line on form -> line number 23

    <Example post title>
    line on form -> line number 40
    line on form -> line number 44

    Is this even possible?

Viewing 1 post (of 1 total)

The topic ‘Orderby meta_key only working on first row in repeater’ is closed to new replies.