Home › Forums › Feature Requests › Options page: post_id for acf_add_options_sub_page
post_id is a great improvement. I was looking for such feature for a long time.
It would be great it there was a possibility to set an ID for sub pages as well.
Why? Because top level pages are usually used to group sub pages (for axample top level page is called Theme Options, and all other pages are sub page of this page). So in this case post_id feature becames useless, because all the sub pages shares the same ID.
Not sure I understand what you mean. Options pages don’t have a post id because they aren’t posts, they are just admin pages and the fields are stored in the WordPress options table.
You’re wrong. Take a look at docs. post_id parameter is set to ‘options’ by default. Possibility to set post_id was introduced in v5.2.7.
okay, I miss things once in a while, especially when I don’t have a reason to use them. and I missed it when I added the autoload feature to my own plugin. Never even noticed it.
Have you tried including a post_id when creating a sub page? Sometimes things are possible that are not documented. I’ll have to check this out. In the mean time I’ll mark this thread for the developer to take a look at when he has time.
To answer the question, yes, you can supply the post_id setting to options sub pages as well and the values entered on the options page will be saved and pulled from the post.
If you are interested I added this feature to my options page adder plugin. https://github.com/Hube2/acf-options-page-adder
It’s a shame but I didn’t even try to set post_id for sub page. I assumed that it’s not posssible because it’s not documented 🙂
There is quite a bit that’s not documented. I knew for example that the two function add_options_page and add_options_sub_page actually both end up calling the same function in the end because I dig around in the code a bit, and I needed to understand how these work to build my plugin.
What bothers me, like I said, is that I completely missed this option when I was adding the autoload option.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.