Home › Forums › Support › When using custom post types and child theme on GP What support do I need to add
- This topic has 15 replies, 3 voices, and was last updated 2 years, 5 months ago by
David.
-
AuthorPosts
-
April 9, 2023 at 7:52 pm #2603522
lionet
– I have made child theme
– I have created a custom postI want to use GP better and need to know more about it.
I looked at the tutorial and used https://generatewp.com/post-type/ to create a custom post type.
I also read https://docs.generatepress.com/article/using-child-theme/I found in generatewp that there is an option to enable and disable support for child themes? I’m confused…
#1 Registering custom posts also needs to enable support for child themes? What do I need to do to make the three work better together when using custom posts and child themes?
#2 Using sub-themes to use GP template hooks, will GP automatically load style sheets in newly registered custom post types?
#3 What is the point of this code? I’m a bit confused. 【if ( ! function_exists(‘custom_post_type’) )】What is the purpose of generatewp adding it to the child theme?
April 9, 2023 at 7:53 pm #2603523lionet
For the convenience of others, here’s our previous post discussing: https://generatepress.com/forums/topic/some-settings-of-gutenbergs-default-modules-are-not-available-on-gp/
April 9, 2023 at 8:05 pm #2603528Fernando Customer Support
Hi Lionet,
1. No. You don’t need to use the Child Theme to create or use Custom Post Types. If you’re planning to change the structure of archive pages and single post pages of your CPTs, then, you do. See here for more info: https://docs.generatepress.com/article/setting-up-a-simple-custom-post-type/
2. How are you using sub-themes? Can you expound a bit more on what you’re trying to do here?
3. That just assures that the function/code to create your Custom Post Type is already defined.
April 10, 2023 at 1:49 am #2603727lionet
2. I just add some simple functions and external styling via child theme. So I’m going to make sure this works on new post types as well.
I use a plugin to register new post types.
3.if ( !function_exists(‘custom_post_type’) )
I added this code and got an error.April 10, 2023 at 1:54 am #2603735Fernando Customer Support
2. No. GP won’t automatically load other stylesheets. You need to enqueue them manually.
3. You’ll need to reach out to Generatewp regarding this as code needed for their CPT to work would be out of our scope.
April 11, 2023 at 1:14 am #2605156lionet
2.Regarding the second question, the use of the child theme, I only need to add styles to the child theme,
No need to enable support, is that what you mean?
A new question, I add this code [add_theme_support( ‘wp-block-styles’ );], but it has no effect?
How do I turn on the core block layout width setting?
April 11, 2023 at 1:58 am #2605216Fernando Customer Support
2. The Child theme has a
style.css
file by default. You can add your styles there. That should be loaded automatically.4. Try just
add_theme_support( 'wp-block-styles' );
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
April 11, 2023 at 6:57 am #2605568lionet
4. I’ve added it, but it doesn’t work. i use code snippets plu-
I’m talking about [Inner blocks use content width] this option
GP has added this feature, but why is it not showing?
add_theme_support(‘align-wide’);Fernando I’m a little dizzy and I need your help.
April 11, 2023 at 7:53 am #2605738lionet
I added code like this:
1. add_theme_support( ‘custom-spacing’ ); This adds an option to modify the padding in the core block settings. The functions are simple and I have understood them. Is this understanding correct?2. add_theme_support( ‘wp-block-styles’ ); Keep the front-end style the same as the default block style. That’s all it’s useful for unless you add custom styles?
For example, if I add a custom block style, it will not be displayed on the front end unless this function is turned on? Am I right?
3. Now my project uses the core block to set the layout and use the width. GP has added the add_theme_support(‘align-wide’); function, but I don’t see the width layout option of the core block, which is [Inner blocks use content width ] Toggle switch?
April 11, 2023 at 6:37 pm #2606419Fernando Customer Support
1. Here’s an article you may refer to: https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#spacing-control
2. See this: https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#default-block-styles
WP Blocks already have default styling though through GP so turning this on won’t be necessary. If you want custom styles, you can add code through Appearance > Customize > Additional CSS.3. See here: https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#wide-alignment
There should be a width setting for WP Blocks through the Toolbar settings, not the Block Settings.
April 11, 2023 at 8:01 pm #2606459lionet
2.Regarding the second point, do you mean that GP has already added similar functionality? So the default styles of the default block are also loaded on the frontend?
3.I’m not talking about gp’s container settings, I’m talking about core blocks, such as group blocks. Why is the layout width setting not used? i want to turn it on
April 11, 2023 at 8:24 pm #2606478Fernando Customer Support
2. Yes, there are default styles loaded on the Frontend for WP Blocks in GP.
3. It should be there by default. See: https://share.getcloudapp.com/Jrup8B21
Or, are you referring to something else?
April 12, 2023 at 2:01 am #2606773lionet
2.I’m making a child theme for GP, and I hope it can load the default styles on the front end, including custom styles added for blocks, and some other things about core blocks. The child theme is also used by other friends who use GP, so Will consider these, although it is not necessary, I add add_theme_support(‘wp -block-styles’); Will it conflict with GP? Or is it recommended that I remove this functionality?
3.Not the place you took the screenshot, I mean this https://imgur.com/a/vELDsPh
April 12, 2023 at 3:58 am #2606917David
StaffCustomer SupportHi there,
2.
add_theme_support(‘wp -block-styles’)
– No, GP does not add this.
those are optional and opinionated styles:GP choose not to add support as it applies styles to common HTML elements, for example: a figure / figcaption that the theme already caters for.
You may find those styles will override theme styles or conflict. I personally see no benefit of adding them.
To see what supports the theme adds check the parent themes functions.php
3. That option is only available on block themes that have a theme.json defining the necessary dimensions.
April 12, 2023 at 7:55 pm #2607977lionet
Thank you David, your answer is what I wanted
-
AuthorPosts
- You must be logged in to reply to this topic.