Hi,
I’m developing my new theme. And I integrate my theme with SiteOrigin Page Builder with TGM Plugin Activation.
I have one custom post type.
My question is, how can I add page builder plugin to my new custom post type without changing on the settings page.
Maybe is there any way to add action and set my custom post slug as a Page Builder support?
Thank you
Hi Imam,
You can do this with SiteOrigin_Panels_Settings::single()->set(‘post-types’, $values).
Set will replace what is currently set so be sure to get the old value with get() and merge your post type with that.
Hi Alex,
Thank you for answering my question.
I don’t understand with your answer, I think above implementation is using PHP Class, right?
Can you show me step by step how to add that code? Should I place that code in my Theme functions.php?
Thank you
Hi Imam,
I can’t really help you with providing exact code but I can however answer your questions.
Yes, it’s a class. I would recommend clicking the links I posted as that’ll show you the exact code.
This will give you an idea of the structure of the post types and give you an idea of how to add it.
Please add that your themes functions.php (or a separate file if desired). Also, please remove the var_dump to prevent it from dumping the row.
Hi, Alex
Thank you for your explanation.
My code is working well.
Is that right?
I have tested it and it’s working.
Thank you Alex :)
Hi Imam,
No, that’s not right. You’re getting the currently active post types and not doing anything them. Instead you’re enabling the post, page and superpage post types and completely disregarding what the user is currently using. Based on this setup, it’s impossible to enable a different post type.
Use this:
I should have suggested a different hook as currently this hook is run on every page load, which isn’t necessary due to it being stored. I would recommend adding this code to your register_activation_hook. It’ll run once (when the plugin has activated) and then won’t run again. This is overall much better.