• Resolved staticore

    (@staticore)


    I have done customization on the Twenty Twenty Two theme – Parent. Both basic custom settings and created new Templates and Template Parts.
    After this I realized I needed a child theme.
    No problem creating the style.css etc and get the child theme to activate.

    But the customized Templates AND Template Parts are not working. Or actually one is, the sidebar. That one is up and looks great.
    But header and footer are gone, no matter what I do it is not possible to customize, I can select one of the main that comes with the theme.

    I have tried (in child theme:
    Create same folders in child theme, copy/paste from parent
    Exported and Added files from FTP
    Create new template parts.
    Add/delete template.json file
    Add/delete function.php file (seems to work best without that one for the settings that works now)
    Add folder block-template-parts instead of template-parts

    Nothing works. I get this message on my site(not in editor): “Template part has been deleted or is unavailable: header”.

    So, I need some help how to solve this. Any suggestions?
    Also, where are these settings for Custom Templates and Parts stored. Directory? Can′t find it anywhere.
    Thanks for any help anyone can give to solve this.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Did you already find a solution? I’m facing the same problem ??

    Thread Starter staticore

    (@staticore)

    Unfortunately, no. I changed back to the parent theme, since I can′t have the site looking like that. Right now I don′t know what more to try than what I wrote in the list above.

    Oke, thanks for your reply, hopefully someone will come up with the answer some day ??

    I’m having the same issue with template parts not showing at all and same error message.

    Thread Starter staticore

    (@staticore)

    I still haven′t found any solution for it.
    Tried again to activate the child theme and tried out different solutions I found when searching the topic but still the same problem no matter what.
    I hope there will be some issue fix for it soon.

    I had trouble getting my child theme to work as well, but after poking it with a stick long enough I was able to get it working by adding this to my child theme’s functions.php file.

    <?php
    /**
     * Twenty Twenty-Two (Child) functions and definitions
     *
     * @link https://developer.www.ads-software.com/themes/basics/theme-functions/
     *
     * @package WordPress
     * @subpackage Twenty_Twenty_Two
     * @since Twenty Twenty-Two 1.0
     */
    
    // Enqueue Child Files
    add_action( 'wp_enqueue_scripts', 'my_plugin_add_stylesheet' );
    function my_plugin_add_stylesheet() {
        wp_enqueue_style( 'my-style', get_stylesheet_directory_uri() . '/style.css', false, '1.0', 'all' );
    }

    No idea if that will be helpful or not. Good luck!

    Thread Starter staticore

    (@staticore)

    Thank you for the advice. Any advice to try is welcome.

    Unfortunately it did not work. Still no header (the code text you posted shows up instead) and can′t access the editor. Gets an error message: The editor is unable to find a block template for the homepage. (SyntaxError: Unexpected token / in JSON at position 0)

    I tried another similar solution earlier but no luck there either.

    May I ask how you did this?
    What files/Folders do you have in your child-theme?
    And have you made changes in the template-parts (not only templates) for the header/footer?

    Thread Starter staticore

    (@staticore)

    I managed to solve it finally.
    Unfortunately I had to remake my header/footer and not sure this is a reliable solution but it works for now and I can add my own code files and .json in the child-theme, that′s good enough for me.

    If anyone else is looking for a way to fix the header/footer problem in child-theme:
    All changes to header & footer are made in the parent template part files with the same name = folder Parts: Header.html & Footer.html. No name changes, no custom template parts. (I could not copy/paste settings from custom templates parts, that caused new issues.)

    My files in the child-theme:
    style.css
    theme.json

    Folders:
    block-template-parts (does not include: header.html, footer.html) all other custom parts seems to work.
    block-templates (includes custom files and needed: index.html)

    index.html = needed to get the editor to work

    I did not add functions.php

    Thank again frgtech for the suggestion, it didn′t work but got me to give it another try and finally solve this.

    Hi- I have a follow-up question: What would be a preferred method of setting up a child theme? Is it recommended to start with a copy of theme.json from the themes folder, activate the child theme and go from there (adding changes)?
    or should I leave theme.json empty and just add what needs to be changed (like I would if I would use functions.php)

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Twenty Twenty Two – Migrate Templates (all settings) to Child Theme’ is closed to new replies.