Support

Account

Forum Replies Created

  • Was able to figure out a solution. Really appreciate the help!

  • Yup, that’s what I was wondering. That stinks. Was hoping I wouldn’t have to do it after fetching. Haven’t seen any articles are sorting after fetching the posts have you?

    Thanks for helping me out on here!

  • I’m doing a terrible job of explaining. I’m having no problems with viewing the data in the arrays and realize it’s an array and been pouring over google.

    But how do I in my original code tell the ‘orderby’ to literally order the meta_value by like ‘$arr[0]’? Or is this not even possible? Currently the ‘orderby’ will not work because it’s an array, so want it to look at just the first value in the array to ‘orderby’.

    Really appreciate your help, hopefully I made a little more sense this time.

  • I really appreciate all your help! Sorry I’m not doing the best job explaining or understanding.

    When I echo the results of ‘application_type’ it is printing out “Array”, unless I do $arr[0] then it will print out like “Bathtub”.

    $arr = get_field('application_type', $post->ID); echo $arr;

    I want my orderby to use just the first item in the Array, currently it won’t even work period, even if just one value in ‘application_type’. I am allowing the admin to select checkboxes, but tried allowing them to select just one value from a drop down and the orderby works great.

    Hopefully I am making a little more sense? Thank you so much for your help!

  • <?php
        $args = array(
          'relation' => 'AND',
          'cat' => 5,
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'meta_query' => array(
            array(
              'key' => 'floor_type',
              'value' => $floor_type
            ),
            array(
              'key' => 'stack_type',
              'value' => $stack_type
            ),
            array(
              'key' => 'plumbing_opening',
              'value' => $plumbing_opening
            )),
          'meta_key' => 'application_type',
          'orderby' => 'meta_value',
          'order' => 'ASC'
        );
        $posts = query_posts($args);
      ?>

    Sorry, I was using the $meta_value as an example. Currently the orderby ‘meta_value’ is an array from client having saved the post with multiple values when selecting the checkboxes. Is it possibly to select just the first item in array to orderby? This make anymore sense. Thank you so much for your help!

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