Support

Account

Home Forums Add-ons Options Page Get a list of defined Option Pages?

Solving

Get a list of defined Option Pages?

  • I am looking for a way to get a list of all the defined Option/Sub Option Pages.
    I only need to know the slugs of each page, but the object would be better.

    I did find that they are listed in $GLOBALS[‘acf_options_pages’].

    Just wondering if there is a better method. Also just adding it here for others.

    Thanks

  • acf_get_options_pages(), not sure what it returns, but pretty sure it just gets what defined in the global

  • For anyone else arriving here later,
    If you check line 425 in options-page.php you’ll see it’s doing a bit more than that. It seems to be applying filters, checking for parent child redirects, returning false if there are no options pages, and finally returning all the pages.

  • Thanks! Was looking for exactly that.

    My use case is an automatic generation of field groups based on registered option pages.
    I’m going to ‘connect’ a Taxonomy to an attachment and needed a UX-friendly way of doing so. So I’ll be making a sort of link table in an option page. Having a Taxonomy dropdown, and a file-field or a media selection field.

    Anyways, I was bummed to find out that acf_get_options_pages() is undocumented and at the moment, I’m not sure if $GLOBALS['acf_options_pages'] is always there. Either way this was exactly what I needed and seems to work flawlessly in ACF Pro 5.11.4.

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

The topic ‘Get a list of defined Option Pages?’ is closed to new replies.