Use on Custom Post Types
-
I have a theme-specific custom post type, and cannot use post & page builder to edit that post-type. I’ve assigned Post & Page Builder as the preferred Editor in the settings, but It does not show up with the drop-down menu as on Pages
-
Hello @fulloutcreative –
In order to use the Post and Page Builder on a Custom Post Type, the CPT must support the feature “editor.”
If your Theme’s Custom Post Type doesn’t support this core feature, you can add it in your functions.php file using code similar to the following with the add_post_type_support function:
add_post_type_support( 'my_post_type', 'editor' );-
This reply was modified 6 years ago by
Jesse Owens. Reason: Fix @ tag
Thanks for the help. I’m using a child theme with a pretty sparse functions.php file. I’ve tried adding the code you provided with variations based on $post_type and cpt_services which is how the template refers to the CPT.
I’ve added this:function add_cpt_services_support() { add_post_type_support( $post_type, 'editor' ); } add_action('init', 'add_cpt_services_support');and tried similar variations
function add_cpt_services_support() { add_post_type_support( 'cpt_services', 'editor' ); } add_action('init', 'add_cpt_services_support');Your second example there should work (the first example would only work if you defined the $post_type variable).
If it’s not, my guess is that it’s running before the CPT gets registered. Try increasing the priority of your add_action to make it run later, like so:
add_action('init', 'add_cpt_services_support', 99);Thanks, still no luck though. I also tried adding it to the functions.php on the parent theme (making a copy first) — triggered debug mode, so that clearly didn’t work. Turns out the CPT is being added by a plugin (trx_addons), does that change where we would place the code?
Hi @fulloutcreative –
It seems like that’s a commercial plugin/theme from themerex .net, and not available for me to download and test with so I can’t say for sure. Are you able to run the commandwp post-type listto verify you have the right handle for the post type?-
This reply was modified 6 years ago by
Jesse Owens. Reason: fix grammar mistake
I wasn’t able to get wp-cli going so I installed a plugin called “Pods – Custom Content Types and Fields” — that plugin listed the handles. For example, I was able to list the “Block Library” and it came back as “bg_block” — similarly the one I am targeting is listed as “cpt_services”
Random thought: WP Bakery is able to be an ‘editor’ for this cpt — would that imply that cpt already supports ‘editor’ ?
Also, that new Pods plugin was available as well when editing a post within Services.
——
I also dug around the Theme Files and found:
$post_type == TRX_ADDONS_CPT_SERVICES_PTI’ve updated the functions.php in the child theme – still no luck — here is the full code of that file (in case something else is missing):
<?php /** * Add excerpt support to pages */ function add_cpt_services_support() { add_post_type_support( 'TRX_ADDONS_CPT_SERVICES_PT', 'editor'); } add_action('init', 'add_cpt_services_support', 99); /** * Child-Theme functions and definitions */ function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );Hi @fulloutcreative
Very sorry for the late reply, I missed the notification email.Since you can see for sure that the post type is called cpt_services then you should use that, not the PHP constant TRX_ADDONS_CPT_SERVICES_PT since that constant might be namespaced or otherwise protected.
You mentioned that WP Bakery supports the post type, does the WordPress Block Editor (Gutenberg) also work? That would indicate that the post type already supports the editor capability.
I’ve reached out to ThemeREX to see if they’re able to provide me with the plugin to see if I can assist you further.
@jessecowens Thank you so much for your help with this. Short answer, yes Gutenberg works.
For Clarity: When I enable (via role manager) WPBakery for that post type I see the buttons for- Backend Editor (wpbakery)
- Frontend Editor (wpbakery)
- Gutenberg Editor
This is similar to what I see when editing a Page just without the top-right dropdown:
- Post & Page Builder
- WordPress Editor
- Classic Editor
-
This reply was modified 6 years ago by
The topic ‘Use on Custom Post Types’ is closed to new replies.