You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Export to register_post_type and register_taxonomy #4
In Pods 2.7, you can hook into the pods_register_taxonomy and pods_register_post_type filters to collect all of the registrations that you'd like, the you can rebuild the register_post_type / register_taxonomy statements to use with your own export code easily from there.
I'll add an option to export to register_post_type / register_taxonomy in this Export to Code plugin too.
@sc0ttkclark Curious if this alternate export method was ever added?
Today while testing this Pods export code to PHP plugin I found that adding the resulting PHP to a theme's functions.php threw a fatal error and does not enable those post types and fields in the admin. It still wants the plugin to be active?
SCF (the ACF clone) exports standalone PHP but I'd prefer to use your more, ethical, project. :-)
While trying to figure out what threw the fatal error, Claude also suggested rewriting the resulting PHP to use only register_post_type() and register_post_meta()
Doing so enabled the exported code from Pods to work wonderfully as a standalone
If Pods could export standalone code it would do 2 things:
enable Pods to be a helper plugin (the way create block theme and create content model are helper plugins for building themes)
enable the fields to all show up natively in the Block Bindings Attributes UI without needing to code the template tags
Here's the resulting code (in my example it's for team bios):
In Pods 2.7, you can hook into the pods_register_taxonomy and pods_register_post_type filters to collect all of the registrations that you'd like, the you can rebuild the register_post_type / register_taxonomy statements to use with your own export code easily from there.
I'll add an option to export to register_post_type / register_taxonomy in this Export to Code plugin too.
Activity
sc0ttkclark commentedon Oct 6, 2017
What modification was that exactly? Happy to bring your tweak over here.
szepeviktor commentedon Oct 6, 2017
Thanks.
var_export instead of var_dump in pods_debug() to make it reversible.
I know I could go
pods_api()->load_pods...but it would need a big chunk of copy of the Pods plugin.sc0ttkclark commentedon Oct 6, 2017
Where are you calling pods_debug() in that code?
sc0ttkclark commentedon Oct 6, 2017
Oh nevermind, I see now it's via the pods_debug_register param flag
szepeviktor commentedon Oct 6, 2017
Nowhere! 😄
Its output is caught and reversed (eval-ed) into PHP arrays.
szepeviktor commentedon Oct 6, 2017
I would rewrite it if you give me instructions that will end up in under 100 lines of code.
Move post type / taxonomy registration
sc0ttkclark commentedon Oct 6, 2017
I think what you came up with is clever, but this PR should make it easier to do what you want:
pods-framework/pods#4498
In Pods 2.7, you can hook into the
pods_register_taxonomyandpods_register_post_typefilters to collect all of the registrations that you'd like, the you can rebuild theregister_post_type/register_taxonomystatements to use with your own export code easily from there.I'll add an option to export to
register_post_type/register_taxonomyin this Export to Code plugin too.[-]Alternative for CPT-s and taxonomies only[/-][+]Export to register_post_type and register_taxonomy[/+]szepeviktor commentedon Oct 6, 2017
I'll start the rewrite as it is released on WP.org.
szepeviktor commentedon Oct 6, 2017
Thank you!
jhmonroe commentedon Mar 10, 2026
@sc0ttkclark Curious if this alternate export method was ever added?
Today while testing this Pods export code to PHP plugin I found that adding the resulting PHP to a theme's functions.php threw a fatal error and does not enable those post types and fields in the admin. It still wants the plugin to be active?
SCF (the ACF clone) exports standalone PHP but I'd prefer to use your more, ethical, project. :-)
While trying to figure out what threw the fatal error, Claude also suggested rewriting the resulting PHP to use only
register_post_type()andregister_post_meta()Doing so enabled the exported code from Pods to work wonderfully as a standalone
If Pods could export standalone code it would do 2 things:
Here's the resulting code (in my example it's for team bios):
It's amazing cause then everything "just works" in the new Block Bindings UI: