• Hi,

    I hope I write it in the correct section, as this presumably applies to Twenty Twenty Two and similar full site editing themes coming in 5.9

    We have a plugin that creates own Custom Post Type (CPT) and has it own single-*CPT* template included in the plugin files.

    The template is quite simple (single-*CPT*.php)

    
    <?php
     /*Template Name: Scrollsequence CPT Template
     */
     
    get_header(); 
    
    // Here is the HTML that works fine
    
    get_footer(); 
    

    All works fine with most themes, even with 5.9. Problem is with Twenty Twenty Two where I am getting this error:

    Deprecated: Theme without header.php is deprecated since version 3.0.0 with no alternative available. Please include a header.php template in your theme. in C:\wamp64

    Same goes for the footer

    Deprecated: Theme without footer.php is deprecated since version 3.0.0 with no alternative available. Please include a footer.php template in your theme. in C:\wamp6

    Anyone else got this error with Full Site Editing enabled Theme?

    Thank you,

    Ales

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hi @scrollsequence

    Twenty Twenty-Two is a block theme and does not contain the header.php and footer.php files. A block theme works differently compared to a non-block theme.

    Thread Starter Scrollsequence

    (@scrollsequence)

    Hi Kaavya,

    Thank you for your prompt response!

    So how can I ensure that when my plugin creates a CPT with custom single-* template that it can be used on standard themes as well as newly introduced block themes?

    Can I somehow check if it is block theme -> do not call header and footer or any similar checks?

    Is there a tutorial on custom post types support for full site editing based themes like Twenty Twenty Two.

    Been looking for some guides on this or example code and can’t find anything. Want to add support to our plugins so they work with block based themes.

    Hi
    To check if a theme is a block theme or not, you can use wp_is_block_theme() (returns true or false) The developer reference has not been updated to include this yet.

    This is only available from WordPress 5.9.0 so you want to check the version / if the function exists.

    I think your best bet at this time, is to look at how WooCommerce or WooCommerce blocks solves the templating.

    I have not found any tutorials that covers this, and have not explored it enough myself. But I know that the woo team have done a lot of preparations for this.

    Thanks for the tip, we are looking into the WooCommerce implementation of FSE

    I don’t understand how any php plugins will work with block themes. How will I write custom php when making a theme? I did a woocommerce site recently and had to pull out all the variation prices into a table for each product. How would I do anything like this with a block theme? Block theme only uses blocks and html. What am I missing?

    @johnfotios It is still largely unexplored. Some thoughts:
    – Place the functionality in a plugin, present it with the theme.
    – If there is functionality that is missing that can benefint everyone, suggest it in the Gutenberg GitHub repository.
    – Use the parts of full site editing that benefits you.

    Block patterns can use PHP, but there are limitations since they do not have access to globals etc.

    If you want to use PHP, you can do that and still use theme.json. One of the differences is that in classic themes, and for PHP templates in block themes, you need to apply the generated CSS on the front yourself.

    If you want to combine PHP templates and HTML templates in a block theme, you can.
    I want to write more about this topic after I have done more testing, but here is one example: https://fullsiteediting.com/lessons/how-to-use-php-templates-in-block-themes/
    (it is already outdated, but gives you an idea)

    @poena thank you for taking the time to reply, your article is very helpful, and this one https://fullsiteediting.com/lessons/adding-full-site-editing-features-to-classic-themes/

    I create websites/custom themes for clients and essentially just use WordPress as a cms. Most of my clients DO NOT want to edit their sites themselves, and it’s me that does all of the editing… so FSE is not necessary as I’m more comfortable writing the code and css.

    Does that sound right to you? FSE looks to be aimed at users who want to change things on their site _after_ installing the theme.

    I love the Gutenberg editor for editing page content, so it’s not that I’m against blocks.

    Dumb question – do you think that ‘classic’ themes will eventually become deprecated?

    I believe that using block markup and theme.json will make it easier for developers. It will be less code to maintain, and much less CSS, -even if you end up having to disable the editor controls for users.

    With block themes you have more options. You can still enqueue scripts and styles, and you can add new CSS to override block alignments and widths etc etc, or even replace the block CSS completely.

    But where you once had to include extra CSS for multiple editors and the front, you can, but you no longer have to because you can choose to let WP handle it for you.

    It is when the features are mature enough that classic themes will be “naturally” deprecated. Not because WordPress will no longer work with older themes, but because there will be no benefits in building themes the old way, other than “I don’t have to learn anything new”.

    Is there an equivalent of locate_template() with support for templates for block themes such as Twenty Twenty-Two?

    Is there an equivalent of locate_template() with support for templates for block themes such as Twenty Twenty-Two?

    I found locate_block_template()

    So how can I ensure that when my plugin creates a CPT with custom single-* template that it can be used on standard themes as well as newly introduced block themes?

    @scrollsequence there is a PHP function to render the header and footer for block templates, however doesn’t include the <html><head></head><body> tags:

    if( wp_is_block_theme() ) {
        block_template_part('header');
    }
    
    if( wp_is_block_theme() ) {
        block_template_part('footer');
    }
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Twenty Twenty Two – CPT Template Error – “Theme without header is deprecated”’ is closed to new replies.