Site logo

[Support request] When using custom post types and child theme on GP What support do I need to add

Home Forums Support [Support request] When using custom post types and child theme on GP What support do I need to add

Home Forums Support When using custom post types and child theme on GP What support do I need to add

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #2603522
    lionet

    – I have made child theme
    – I have created a custom post

    I 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?

    #2603523
    lionet

    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/

    #2603528
    Fernando
    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.

    #2603727
    lionet

    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.

    #2603735
    Fernando
    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.

    #2605156
    lionet

    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?

    #2605216
    Fernando
    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

    #2605568
    lionet

    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.

    #2605738
    lionet

    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?

    #2606419
    Fernando
    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.

    #2606459
    lionet

    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

    #2606478
    Fernando
    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?

    #2606773
    lionet

    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

    #2606917
    David
    Staff
    Customer Support

    Hi there,

    2. add_theme_support(‘wp -block-styles’) – No, GP does not add this.
    those are optional and opinionated styles:

    https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#default-block-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.

    #2607977
    lionet

    Thank you David, your answer is what I wanted

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.