Open tech-knowledgy opened 1 year ago
Hi @tech-knowledgy, thanks for the report. We've been able to replicate this and will get it fixed up in a future release.
@tech-knowledgy Just to clarify, the menu_position
parameter is actually what's used to save the "Menu Position" setting and set the position of the CPT in the menu, and in my testing that appears to be set correctly in the JSON files.
The menu_order
param is internal to ACF and is at the moment unused, so we may end up removing that from the JSON export to prevent confusion. This tripped me up for a minute as well!
When another dev imports the JSON file, it isn't keeping order based on what another dev has instructed the CPT order to be. When hand-massaging this value in the JSON and then importing, it does keep the correct value.
Because the JSON file will always render out a 0
, it isn't appearing to import properly without this manual file manipulation.
The end goal is to ensure the order is consistent among all devs based on the JSON file since it's configured through ACF and saved to disk through the ACF filter.
@tech-knowledgy by CPT order, are you referencing where that CPT shows up in the sidebar on the left?
If so, that should be the menu_position
param rather than the menu_order
param. Does the menu_position
param show up in your JSON file, and is that 0
as well?
Yes, where they appear in the sidebar on the left.
menu_position
does not seem to be honored after the value 4
.
1
- Very top (above Dashboard
entry)
2
- Just below Dashboard
entry
3
- Same visible location as 2
(likely replacing a non-visible separator)
4
- Far down in 9th spot
This item positioned in spot 4
is far below other CPT's created by ACF that have higher valued menu_position
settings (we have up to 9 so far).
However, as stated in the original post, as well as in the follow-up, manually manipulating menu_order
, regardless of what menu_position
holds, resolves the issue. But as soon as we make any changes to the CPT, the value is reset to 0, and order is jumbled up in a nonsensical manner. I'm sure there is sense to it, but it's certainly not honoring the values we set to them. In fact, we can intentionally change menu_position
in the JSON files by hand and as long as menu_order
is correct, it is indeed ordering as we expect.
This test can be performed on a brand new install of Wordpress 6.3.1, ACF Pro 6.2.1.1, literally no code changes, default WP theme, and you don't even have to import/sync the JSON files to see the effects. I've attempted to create CPTs from scratch and get the same result.
I searched the source and only see menu_position
referenced twice: once for the Advanced Options UI, and the other when establishing $args
for a filter of acf/post_type/registration_args
.
Maybe I'm blind or my search-fu is failing me, but I don't see this filter being utilized anywhere - so the fact it is updating to some degree kinda baffles me, but I don't know the deep internals of ACF nor pretend to.
However, when I searched the source for menu_order
, I do see it referenced significantly more.
I'm not sure what to tell you other than to attempt creating a handful of CPTs and adjusting their order, and you shouldn't see the values you set honored correctly.
On an aside, the order not being honored also holds true for Field Groups that are set as Side
for a Advanced > Presentation > Position
, but that's not as pressing for us at the moment. I haven't tested order in the Normal (after content)
setting as they're appearing in the order added to the Field Group which is fine-enough for us at the moment.
Here's what it looks like when I create 4 entries, named Pos 4->7 and given those exact menu_position
values:
Attached is the JSON as it is exported from the UI acf-export-2023-09-21.zip
Describe the bug Whether manually exporting as JSON, or using the
acf/settings/save_json
filter,menu_order
always reverts to 0To Reproduce Steps to reproduce the behavior:
Post Types
Tools
pagemenu_order
is 0, although UI reflects correct valueExpected behavior JSON Should 100% reflect what's stored in the database.
Code Straightforward filter usage based on docs:
Version Information: