NO BUG: Loop Order by not working using ACPT fields

Browser: Firefox
OS: Linux
URL: local
Video: Short screen recording that illustrates this issue (free tools: birdeatsbug.com or jam.dev)

Hi, I am struggling to get a Loop to Order by a field created in ACPT.

Create a ACPT custom post type.
Add a single field ( metabox ) to it. I used Orderfield set to Numeric.

Create some test CPTs adding random numbers to the Orderfield field.

Create a page with a Query Loop
In the Query I have
Order by - Meta numeric value
Order meta key - orderfield
Order - Ascending

Also in the Loop I have a Basic text element to display the post name and orderfield.

In this case the loop displays nothing, its just blank.
If I remove the value in Order meta key then the loop displays all my posts but they are not ordered, well ordered by creation date.

After seeing a similar report for Metabox fields I tried changing the ACPT orderfield to a text value and updated all the posts to use values such as 01, 02 etc. But this gives identical results. ( How to:
Custom Post Order Query Loop / Metabox )

So a couple of points:
How should the Order by actually work? When it says Meta numeric value then I’d assume it should require a numeric field.

Is this a bug with the ACPT integration or am I doing something wrong?

The intention is to be able to sort the custom posts using a numeric value ( actually a magazine issue number ). I don’t want to have to use the 01, 02 format as I can’t rely on my customer actually remembering to use that format ( there may be over 100 issues ).

Cheers
Alan

Hey Alan,

thanks for your report.

Hard to tell without having a look at the actual site / setup. Please send some temporary credentials to help@bricksbuilder.io and include a link to this forum thread. Then I’m happy to have a look.

Best,

André

Andre,
Thanks. This is just a test local setup so I’ll try and create an external version.
But really simple setup. Just some sample posts and the query loop as above.

Cheers
Alan

Hey Alan,

but not simple enough to work obviously. :smiley: Maybe you can at least show me a screenshot of your custom field setup in Meta Box.

Best,

André

Hi, New site created and login link sent to help@bricksbuilder.io.

Custom Post type and fields are all created in ACPT not Metabox. Confusingly ACPT does use the term metabox to identify its fields!

Cheers
Alan

Hey Alan,

thanks for the credentials.

The custom field is stored in the database as testcpt1metabox_orderfieldnumeric.

This is the meta key you have to use for your query. Then it works as expected.

Best,

André

Wow thank you so much!

I had tried using the cf_testcpt1metabox_orderfieldnumeric and as suggested elsewhere just the orderfieldnumeric. So other than checking in the database is there an easy way to tell what field name should be used?

I’ll ask Mauro if it is possible to highlight the actual fieldname to be used on the ACPT pages.

Hey Alan,

yes. This totally depends on how the plugin stores its data in the database. So it’s probably best to talk to its creator. :slight_smile:

Best,

André

As an aside to this …
Is there any reason why the “Order meta key” can not show a list of available variables, same as a normal dynamic field?

1 Like

Hey @alanj I am having the same problem, how did you solve finding the correct meta key to sort the custom post type? I have custom posts that I want to sort by the custom date field.

How To Order a Query Loop Based On Date Custom Field By Using ACPT Plugin.

@wiggy check this one :point_up:

2 Likes