• Resolved adambundy

    (@adambundy)


    Hello, I am trying to use the plugin to create a custom query that shows pages (post_type=page) which are children of page X, then order them manually. So, I created a new ACF field (type=number) and set that field group to show in the Rest API. I assigned some values to a few of the pages involved in order to test.

    Under the query block’s Post Order section, I have set my query to order by ‘meta value num’ and ASC. Then as suggested, under Post Meta Query I set the meta key to ‘page_order’, value to 0 (zero), and compare to !=. Oddly, when I start typing ‘page_order’ under meta key, this meta key’s name doesn’t pop up in the suggestions, making me think that the plugin can’t see it even though I have ACF set to show this field group in the Rest API (maybe this points to the issue).

    This sorting by meta key doesn’t seem to work, either in the block editor’s display or on the front-end page. It seems to sort them according to whatever the ‘order by’ select menu is set to (which is either by date or title), without regard for what I have set down in the meta query settings.

    Any help is much appreciated. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ryan Welcher

    (@welcher)

    Sorry for the delay in getting back to you here. The short answer is that ACF stores its meta in a different place the WordPress core so that is why the meta fields are not appearing.

    At this point, AQL doesn’t have built in ACF support.

    Thread Starter adambundy

    (@adambundy)

    @welcher thanks much for your response. However, these ACF fields’ values are/were showing up as regular wordpress meta values, so it should be able to utilize them like any other custom field values. I ended up going another route for this, and rolling my own custom query, and for reference, the following query works to get the pages I want and put them in order, by value, of my custom field (‘page_order’):

    $args = array(
    'post_type' => 'page',
    'post_parent' => 7665,
    'posts_per_page' => -1,
    'meta_key' => 'page_order',
    'orderby' => 'meta_value_num',
    'order' => 'ASC',
    );

    It seems maybe this aspect of the plugin has an issue, or the problem is that somehow ACF stores fields’ values in such a way that its possible to use them in a custom WP query but not in the way the plugin accesses these values. Maybe something to do with Rest API – see my notes on that in the OP.

    Thanks!

    Plugin Author Ryan Welcher

    (@welcher)

    Just to clarify, ACF fields are sorted in a different place in the REST response that standard meta. Standard meta is stored under a meta key while ACF is stored under acf . This is why the ACF fields were not appearing as options to select. You can still manually enter the key name and hit enter to store it in the Meta Key field and they will be used in the query as expected.

    • This reply was modified 1 year, 4 months ago by Ryan Welcher.
    Plugin Author Ryan Welcher

    (@welcher)

    I just released version 2.1.0 which supports ACF fields in the autocomplete drop down for the Post Meta queries and should address this issue. Thanks for your patience on this!

    I’m going to close this out as resolved but feel free to open a new issue if needed.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trying to filter pages to children of page, order by meta_value_num (ACF field)’ is closed to new replies.