Custom Post Types (again)
-
Unfortunately does not work with Custom Post types with WP 6.7.1
-
This topic was modified 1 year, 6 months ago by
takeok.
-
This topic was modified 1 year, 6 months ago by
-
Hey, @takeok, what have you done to test this? I can confirm this plugin does work with CPT when on WP 6.7.1
Would you like help debugging your issue?
Thanks for letting me know it’s working for you. I will try to understand the issue better and report back soon.
Ok it’s working on the frontend… it’s just in the Editor that the selected posts are not being rendered. The Editor appears to just be using the standard query parameters without the post__in modification. So when I switch to the post type to “Testimonials” for example and choose “Testimonial Four” the editor still just shows Testimonial One, Testimonial Two, etc…
And you’re definitely on the latest version–1.0.2–right? I know we fixed a similar backend issue previously. My tests are working, too. https://ocl.ink/v/vgcYpQ
I’ve created a test CPT using the ACF UI (the CPT I was using before is being created by theme code / PHP) and the test CPT is working. So it has something to do with the way the theme is registering the CPT I was trying to use. show_in_rest and it’s set to true. Not sure what else it might be.
Let me check with my team and see what ideas we can come up with.
Ok it’s not anything in the register_post_type() function. I tried exporting my working “Test CPT” that I created in ACF as PHP, deleted it in ACF and then copy/pasted the exact ACF PHP code at the bottom of the functions.php file and… doesn’t work.
So it doesn’t work when the CPT is registered via the theme’s functions.php. But it does work when the CPT is registered via ACF. The Theme is sage (ugg)
p.s. I’ve noticed my custom post type registered via PHP in the theme isn’t being returned in line 49 of /query-loop-post-selector.php
p.p.s. using the ‘after_setup_theme’ action in the theme to register the CPT instead of the ‘init’ action makes it work without any changes to the plugin. So that’s probably a good workaround. Unless there’s another hook that can be used in the plugin that will work when CPTs are registered with ‘init’
Perhaps it would make sense for the plugin to use ‘wp_loaded’ instead? Although it works fine when I register my CPT via ACF. Anyway I have a workaround and we know the issue has to do with when the timing of when the theme registers the CPTs and when your plugin looks for the CPTs so I’ll leave that with you. Thanks for being so responsive!
-
This reply was modified 1 year, 6 months ago by
takeok.
Thanks for the troubleshooting and feedback! I confirmed that Custom Post Type UI’s export code also uses the
inithook; it wouldn’t be reasonable–in my opinion–to expect users to know to change that. So we’re discussing how we want to modify our plugin. I think your suggestion would work, or perhaps we’ll set a priority on ourinitcall. Either way, I expect we’ll release an update in the coming days!Awesome. I’ll mark as resolved on the assumption an update is coming soon.
-
This reply was modified 1 year, 6 months ago by
The topic ‘Custom Post Types (again)’ is closed to new replies.