Home › Forums › Add-ons › Options Page › Option Pages does not work when submenu pages are there
When adding “add_submenu_page()” to “acf_add_options_page()” redirect “false” is not respected.
See without add_submenu_age() – https://ibb.co/GPGfj3k
After adding – https://ibb.co/8jHW0dV
When I click on “Lynteo” I go to “Global Blocks” not to Lynteo Option Page.
Is there a reason you’re using add_submenu_page() instead of acf_add_options_sub_page()
I have no idea what you’re doing because I can’t read any of the code in those images. Maybe try posting the code you are using here.
Only thing I did is:
– acf_add_options_page with “redirect: false”
– and then “add_submenu_page()” which negates the redirect and makes it “true” basically
Why? Because I have ACF Option Page ad main where I have settings. It’s for my plugin. After that I need custom pages (mosty currently used to hide CPT my plugin creates).
So when I click on the “first” item I see Option Page but there is submenu with more subpages I need.
Correct me if I am wrong, but why should I use “acf_add_options_sub_page” to link to CPT or show custom content (not related to ACF)? This function does not support that, so I use default WordPress way
PS: I managed to have it working (add acf subpage and the main option page is redirecting to it).
I do know that it works/or does not work when mixing acf options pages with other types of admin menu items. I don’t know why you are seeing this issue when using a WP sub menu page as a sub page of an ACF options page.
This has a lot to do with the priority when adding the page or sub page. For example, due to priority of the ACF options page addition it is quite complicated to add a CPT as a sub page. It could be that there is a similar situation happening with mixing and acf options page with wp sub pages. See my explanation and fix for adding a CPT as a submenu item of an ACF options page here, it might help you. https://github.com/Hube2/acf-filters-and-functions/blob/master/acf-options-page-w-cpt-children.php
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.