Bug: Archive Remains when Enable Archive is unchecked
Issue Overview
After checking 'Enable Archive Page' (and providing an Archive Page Slug Override) in Edit Pods, Advanced Options, archive is enabled. Unchecking (to disable the archive), the archive remains 'enabled' in WordPress, even though Pods Admin shows the archive is not 'Enabled'.
Expected Behavior
Disabling Archive should NOT leave it 'enabled' (has_archive should still represent as 'false' and there should not be a rewrite rule that points to the archives.
Current Behavior
Enabling Archives, enables archive. Unchecking 'Enable Archive Page' leaves the archive enabled.
Archive is Unchecked

View Tests (View Archive is still available

Archive Front-end Post Type Archives: Tests is still visible

Steps to Reproduce (for bugs)
- Create a Custom Post Type
- Enable Archive under Advanced Options, 'Enable Archive Page'. Save and verify it works.
- Edit pod, and Uncheck 'Enable Archive Page'. Save and Pods Settings, Clear Cache (just in case)
- Visit Custom Post Type and see that View Archives is still available.
Current Pods Version 2.7.12
This was reported on Slack today and validated locally by me.
@jimtrue: I'm curious if clearing the Pods cache straightens it out.
@pglewis Please see notes above in the issue. Clearing the pods cache doesn't fix this.
Ah, I did read through, just missed that bit.
Hi, I am seeing the same error listed above.
I enabled the archive page for a pod. Later on I decided I didn't want the archive page. I unchecked the "Enable Archive Page" under Advanced Options. Unfortunately the archive page still operates.
Thanks
I resolved it by enabling archive page, then remove the text in the 'slug' field that appears and disabling the archive page again. Then go to settings--> permalinks and click save (as far as I know this triggers permalink rewrites). That solved it for me.
Hi @Driekes This indeed sounds like a permalink cache issue.
@sc0ttkclark
- Line that triggers cache flush: https://github.com/pods-framework/pods/blob/main/classes/PodsAPI.php#L2401
- Line that triggers cache refresh transient: https://github.com/pods-framework/pods/blob/main/classes/PodsAPI.php#L9229
- Actual rewrite refresh (after
wp_loaded): https://github.com/pods-framework/pods/blob/main/classes/PodsInit.php#L1469
What I noticed is that using the function flush_rewrite_rules() defaults to a hard flush while we only do a soft flush. A particular reason for this?
EDIT:
I also don't really understand why we use a transient for this while WP already has the whole action handling done for flushing rewrites, you can just run flush_rewrite_rules() and WP handles the rest right?
Might it not be the case that the slug is used even if the archive checkmark is set to off? Not sure if this is just a cache issue, but you'll know better 👍🏻
Came here to file this same issue. I too had to make sure to remove the text from the custom Slug Override field before unchecking the box. That was enough to fix the issue, without having to flush permalinks.
Patch can be tested! See pull request: #6069